aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-21 23:51:21 +0000
committerChris Lattner <sabre@nondot.org>2002-08-21 23:51:21 +0000
commit0383cc4455f59b081317d95f46f7b2c068ff6ae1 (patch)
tree3b60bec6665b528a31dccbe1868041ceb756d71e
parentc37fca1492a26e0eb4eb1e77833a1489fa73ff62 (diff)
- Fix asmparser and bytecode reader to not generate loads/stores with idxs
Now an obnoxious warning is emitted to discourage usage. Eventually support will be removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3435 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AsmParser/llvmAsmParser.y39
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 8d7891b002..7edbfbcefa 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -43,6 +43,14 @@ string CurFilename;
#define YYERROR_VERBOSE 1
+// HACK ALERT: This variable is used to implement the automatic conversion of
+// load/store instructions with indexes into a load/store + getelementptr pair
+// of instructions. When this compatiblity "Feature" is removed, this should be
+// too.
+//
+static BasicBlock *CurBB;
+
+
// This contains info used when building the body of a function. It is
// destroyed when the function is completed.
//
@@ -1366,7 +1374,7 @@ InstructionList : InstructionList Inst {
$$ = $1;
}
| /* empty */ {
- $$ = new BasicBlock();
+ $$ = CurBB = new BasicBlock();
};
BBTerminatorInst : RET ResolvedVal { // Return with a result...
@@ -1633,7 +1641,19 @@ MemoryInst : MALLOC Types {
if (LoadInst::getIndexedType(*$2, *$4) == 0)
ThrowException("Invalid indices for load instruction!");
- $$ = new LoadInst(getVal(*$2, $3), *$4);
+ Value *Src = getVal(*$2, $3);
+ if (!$4->empty()) {
+ std::cerr << "WARNING: Use of index load instruction:"
+ << " replacing with getelementptr/load pair.\n";
+ // Create a getelementptr hack instruction to do the right thing for
+ // compatibility.
+ //
+ Instruction *I = new GetElementPtrInst(Src, *$4);
+ CurBB->getInstList().push_back(I);
+ Src = I;
+ }
+
+ $$ = new LoadInst(Src);
delete $4; // Free the vector...
delete $2;
}
@@ -1647,7 +1667,20 @@ MemoryInst : MALLOC Types {
if (ElTy != $2->getType())
ThrowException("Can't store '" + $2->getType()->getDescription() +
"' into space of type '" + ElTy->getDescription() + "'!");
- $$ = new StoreInst($2, getVal(*$4, $5), *$6);
+
+ Value *Ptr = getVal(*$4, $5);
+ if (!$6->empty()) {
+ std::cerr << "WARNING: Use of index store instruction:"
+ << " replacing with getelementptr/store pair.\n";
+ // Create a getelementptr hack instruction to do the right thing for
+ // compatibility.
+ //
+ Instruction *I = new GetElementPtrInst(Ptr, *$6);
+ CurBB->getInstList().push_back(I);
+ Ptr = I;
+ }
+
+ $$ = new StoreInst($2, Ptr);
delete $4; delete $6;
}
| GETELEMENTPTR Types ValueRef IndexList {