mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-13 16:03:58 +00:00
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
This commit is contained in:
parent
8f85748178
commit
46f5c11bed
@ -1356,23 +1356,18 @@ void CppWriter::printInstruction(const Instruction *I,
|
||||
}
|
||||
case Instruction::GetElementPtr: {
|
||||
const GetElementPtrInst* gep = cast<GetElementPtrInst>(I);
|
||||
if (gep->getNumOperands() <= 2) {
|
||||
Out << "GetElementPtrInst* " << iName << " = GetElementPtrInst::Create("
|
||||
<< opNames[0];
|
||||
if (gep->getNumOperands() == 2)
|
||||
Out << ", " << opNames[1];
|
||||
} else {
|
||||
Out << "std::vector<Value*> " << iName << "_indices;";
|
||||
nl(Out);
|
||||
for (unsigned i = 1; i < gep->getNumOperands(); ++i ) {
|
||||
Out << iName << "_indices.push_back("
|
||||
<< opNames[i] << ");";
|
||||
nl(Out);
|
||||
Out << "GetElementPtrInst* " << iName << " = GetElementPtrInst::Create("
|
||||
<< getCppName(gep->getSourceElementType()) << ", " << opNames[0] << ", {";
|
||||
in();
|
||||
for (unsigned i = 1; i < gep->getNumOperands(); ++i ) {
|
||||
if (i != 1) {
|
||||
Out << ", ";
|
||||
}
|
||||
Out << "Instruction* " << iName << " = GetElementPtrInst::Create("
|
||||
<< opNames[0] << ", " << iName << "_indices";
|
||||
nl(Out);
|
||||
Out << opNames[i];
|
||||
}
|
||||
Out << ", \"";
|
||||
out();
|
||||
nl(Out) << "}, \"";
|
||||
printEscapedString(gep->getName());
|
||||
Out << "\", " << bbname << ");";
|
||||
break;
|
||||
|
10
test/CodeGen/CPP/gep.ll
Normal file
10
test/CodeGen/CPP/gep.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llc -march=cpp -o - %s | FileCheck %s
|
||||
|
||||
define void @f1(i32* %addr) {
|
||||
%x = getelementptr i32, i32* %addr, i32 1
|
||||
; CHECK: ConstantInt* [[INT_1:.*]] = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10));
|
||||
; CHECK: GetElementPtrInst::Create(IntegerType::get(mod->getContext(), 32), ptr_addr,
|
||||
; CHECK-NEXT: [[INT_1]]
|
||||
; CHECK-NEXT: }, "x", label_3);
|
||||
ret void
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user