aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Sparc
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-04-07 17:29:37 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-04-07 17:29:37 +0000
commitf3334ebbe3b707ed14c1736ff86d2e5ac26298f7 (patch)
tree373aa751b56dd84771a737de015c46479ae0304c /lib/Target/Sparc
parent562cb16381ede505e1a76efc5aaab22b35cb808d (diff)
downloadexternal_llvm-f3334ebbe3b707ed14c1736ff86d2e5ac26298f7.zip
external_llvm-f3334ebbe3b707ed14c1736ff86d2e5ac26298f7.tar.gz
external_llvm-f3334ebbe3b707ed14c1736ff86d2e5ac26298f7.tar.bz2
First version of code to handle loads. Stub function for handling stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc')
-rw-r--r--lib/Target/Sparc/InstSelectSimple.cpp40
-rw-r--r--lib/Target/Sparc/SparcV8ISelSimple.cpp40
2 files changed, 78 insertions, 2 deletions
diff --git a/lib/Target/Sparc/InstSelectSimple.cpp b/lib/Target/Sparc/InstSelectSimple.cpp
index 23dfeff..f8b8a88 100644
--- a/lib/Target/Sparc/InstSelectSimple.cpp
+++ b/lib/Target/Sparc/InstSelectSimple.cpp
@@ -61,7 +61,9 @@ namespace {
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
void visitSetCondInst(Instruction &I);
void visitCallInst(CallInst &I);
- void visitReturnInst(ReturnInst &RI);
+ void visitReturnInst(ReturnInst &I);
+ void visitLoadInst(LoadInst &I);
+ void visitStoreInst(StoreInst &I);
void visitInstruction(Instruction &I) {
std::cerr << "Unhandled instruction: " << I;
@@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
return true;
}
+void V8ISel::visitLoadInst(LoadInst &I) {
+ unsigned DestReg = getReg (I);
+ unsigned PtrReg = getReg (I.getOperand (0));
+ switch (getClass (I.getType ())) {
+ case cByte:
+ if (I.getType ()->isSigned ())
+ BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ else
+ BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cShort:
+ if (I.getType ()->isSigned ())
+ BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ else
+ BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cInt:
+ BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cLong:
+ BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ default:
+ std::cerr << "Load instruction not handled: " << I;
+ abort ();
+ return;
+ }
+}
+
+void V8ISel::visitStoreInst(StoreInst &I) {
+ unsigned SrcReg = getReg (I.getOperand (0));
+ unsigned PtrReg = getReg (I.getOperand (1));
+ std::cerr << "Store instruction not handled: " << I;
+ abort ();
+}
+
void V8ISel::visitCallInst(CallInst &I) {
assert (I.getNumOperands () < 8
&& "Can't handle pushing excess call args on the stack yet");
diff --git a/lib/Target/Sparc/SparcV8ISelSimple.cpp b/lib/Target/Sparc/SparcV8ISelSimple.cpp
index 23dfeff..f8b8a88 100644
--- a/lib/Target/Sparc/SparcV8ISelSimple.cpp
+++ b/lib/Target/Sparc/SparcV8ISelSimple.cpp
@@ -61,7 +61,9 @@ namespace {
void visitShiftInstruction(Instruction &I) { visitBinaryOperator(I); }
void visitSetCondInst(Instruction &I);
void visitCallInst(CallInst &I);
- void visitReturnInst(ReturnInst &RI);
+ void visitReturnInst(ReturnInst &I);
+ void visitLoadInst(LoadInst &I);
+ void visitStoreInst(StoreInst &I);
void visitInstruction(Instruction &I) {
std::cerr << "Unhandled instruction: " << I;
@@ -280,6 +282,42 @@ bool V8ISel::runOnFunction(Function &Fn) {
return true;
}
+void V8ISel::visitLoadInst(LoadInst &I) {
+ unsigned DestReg = getReg (I);
+ unsigned PtrReg = getReg (I.getOperand (0));
+ switch (getClass (I.getType ())) {
+ case cByte:
+ if (I.getType ()->isSigned ())
+ BuildMI (BB, V8::LDSBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ else
+ BuildMI (BB, V8::LDUBmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cShort:
+ if (I.getType ()->isSigned ())
+ BuildMI (BB, V8::LDSHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ else
+ BuildMI (BB, V8::LDUHmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cInt:
+ BuildMI (BB, V8::LDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ case cLong:
+ BuildMI (BB, V8::LDDmr, 1, DestReg).addReg (PtrReg).addSImm(0);
+ return;
+ default:
+ std::cerr << "Load instruction not handled: " << I;
+ abort ();
+ return;
+ }
+}
+
+void V8ISel::visitStoreInst(StoreInst &I) {
+ unsigned SrcReg = getReg (I.getOperand (0));
+ unsigned PtrReg = getReg (I.getOperand (1));
+ std::cerr << "Store instruction not handled: " << I;
+ abort ();
+}
+
void V8ISel::visitCallInst(CallInst &I) {
assert (I.getNumOperands () < 8
&& "Can't handle pushing excess call args on the stack yet");