llvm.org GIT mirror llvm / 46f5c11
Fix CPP Backend for GEP API changes for opaque pointer types Based on a patch by Jerome Witmann. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247047 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 5 years ago
2 changed file(s) with 21 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
13551355 }
13561356 case Instruction::GetElementPtr: {
13571357 const GetElementPtrInst* gep = cast(I);
1358 if (gep->getNumOperands() <= 2) {
1359 Out << "GetElementPtrInst* " << iName << " = GetElementPtrInst::Create("
1360 << opNames[0];
1361 if (gep->getNumOperands() == 2)
1362 Out << ", " << opNames[1];
1363 } else {
1364 Out << "std::vector " << iName << "_indices;";
1365 nl(Out);
1366 for (unsigned i = 1; i < gep->getNumOperands(); ++i ) {
1367 Out << iName << "_indices.push_back("
1368 << opNames[i] << ");";
1369 nl(Out);
1358 Out << "GetElementPtrInst* " << iName << " = GetElementPtrInst::Create("
1359 << getCppName(gep->getSourceElementType()) << ", " << opNames[0] << ", {";
1360 in();
1361 for (unsigned i = 1; i < gep->getNumOperands(); ++i ) {
1362 if (i != 1) {
1363 Out << ", ";
13701364 }
1371 Out << "Instruction* " << iName << " = GetElementPtrInst::Create("
1372 << opNames[0] << ", " << iName << "_indices";
1373 }
1374 Out << ", \"";
1365 nl(Out);
1366 Out << opNames[i];
1367 }
1368 out();
1369 nl(Out) << "}, \"";
13751370 printEscapedString(gep->getName());
13761371 Out << "\", " << bbname << ");";
13771372 break;
0 ; RUN: llc -march=cpp -o - %s | FileCheck %s
1
2 define void @f1(i32* %addr) {
3 %x = getelementptr i32, i32* %addr, i32 1
4 ; CHECK: ConstantInt* [[INT_1:.*]] = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
5 ; CHECK: GetElementPtrInst::Create(IntegerType::get(mod->getContext(), 32), ptr_addr,
6 ; CHECK-NEXT: [[INT_1]]
7 ; CHECK-NEXT: }, "x", label_3);
8 ret void
9 }