diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-04-04 20:44:05 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-04-04 20:44:05 +0000 |
| commit | dfcf8e34cf71f8262981ce113afa451a8e684d91 (patch) | |
| tree | 7ff2c93509a993906de380e79c5c45d6278c25af /llvm/lib | |
| parent | ca76d11a819418f1cd0236adad7878c188350bc4 (diff) | |
| download | bcm5719-llvm-dfcf8e34cf71f8262981ce113afa451a8e684d91.tar.gz bcm5719-llvm-dfcf8e34cf71f8262981ce113afa451a8e684d91.zip | |
In the perhaps not-to-distant future, we might support gep instructions that
have non-long indices for sequential types. In order to avoid trying to figure
out how the v9 backend works, we'll just hack it in the preselection pass.
llvm-svn: 12647
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp b/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp index 9677b45a2e2..2677d4ce26b 100644 --- a/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -24,12 +24,12 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Support/InstVisitor.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/Scalar.h" #include <algorithm> - -namespace llvm { +using namespace llvm; namespace { @@ -228,6 +228,23 @@ inline void PreSelection::visitInstruction(Instruction &I) { void PreSelection::visitGetElementPtrInst(GetElementPtrInst &I) { Instruction* curI = &I; + // The Sparc backend doesn't handle array indexes that are not long types, so + // insert a cast from whatever it is to long, if the sequential type index is + // not a long already. + unsigned Idx = 1; + for (gep_type_iterator TI = gep_type_begin(I), E = gep_type_end(I); TI != E; + ++TI, ++Idx) + if (isa<SequentialType>(*TI) && + I.getOperand(Idx)->getType() != Type::LongTy) { + Value *Op = I.getOperand(Idx); + if (Op->getType()->isUnsigned()) // Must sign extend! + Op = new CastInst(Op, Op->getType()->getSignedVersion(), "v9", &I); + if (Op->getType() != Type::LongTy) + Op = new CastInst(Op, Type::LongTy, "v9", &I); + I.setOperand(Idx, Op); + } + + // Decompose multidimensional array references if (I.getNumIndices() >= 2) { // DecomposeArrayRef() replaces I and deletes it, if successful, @@ -251,8 +268,6 @@ void PreSelection::visitCallInst(CallInst &I) { /// createPreSelectionPass - Public entry point for the PreSelection pass /// -FunctionPass* createPreSelectionPass(const TargetMachine &TM) { +FunctionPass* llvm::createPreSelectionPass(const TargetMachine &TM) { return new PreSelection(TM); } - -} // End llvm namespace |

