aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Sparc/SparcV8ISelSimple.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-03-04 00:56:25 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-03-04 00:56:25 +0000
commite806173ab6f571f48e8b056fbd355ccef4371a23 (patch)
treeefbd721350888058dfc70b2176bd9d6fc6e3467c /lib/Target/Sparc/SparcV8ISelSimple.cpp
parentbc1d27aa6e80022d507ce4811566b4af4257ee45 (diff)
downloadexternal_llvm-e806173ab6f571f48e8b056fbd355ccef4371a23.zip
external_llvm-e806173ab6f571f48e8b056fbd355ccef4371a23.tar.gz
external_llvm-e806173ab6f571f48e8b056fbd355ccef4371a23.tar.bz2
Simple copyConstantToReg support, SETHIi and ORri
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Sparc/SparcV8ISelSimple.cpp')
-rw-r--r--lib/Target/Sparc/SparcV8ISelSimple.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Target/Sparc/SparcV8ISelSimple.cpp b/lib/Target/Sparc/SparcV8ISelSimple.cpp
index 63d3dcc..95ff31e 100644
--- a/lib/Target/Sparc/SparcV8ISelSimple.cpp
+++ b/lib/Target/Sparc/SparcV8ISelSimple.cpp
@@ -167,11 +167,27 @@ void V8ISel::copyConstantToRegister(MachineBasicBlock *MBB,
Constant *C, unsigned R) {
if (C->getType()->isIntegral()) {
unsigned Class = getClass(C->getType());
-
ConstantInt *CI = cast<ConstantInt>(C);
- // cByte: or %g0, <imm>, <dest>
- // cShort or cInt: sethi, then or
- // BuildMI(*MBB, IP, <opcode>, <#regs>, R).addImm(CI->getRawValue());
+ switch (Class) {
+ case cByte:
+ BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (V8::G0).addImm ((uint8_t) CI->getRawValue ());
+ return;
+ case cShort: {
+ unsigned TmpReg = makeAnotherReg (C->getType ());
+ BuildMI (*MBB, IP, V8::SETHIi, 1, TmpReg).addImm (((uint16_t) CI->getRawValue ()) >> 10);
+ BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (TmpReg).addImm (((uint16_t) CI->getRawValue ()) & 0x03ff);
+ return;
+ }
+ case cInt: {
+ unsigned TmpReg = makeAnotherReg (C->getType ());
+ BuildMI (*MBB, IP, V8::SETHIi, 1, TmpReg).addImm (((uint32_t) CI->getRawValue ()) >> 10);
+ BuildMI (*MBB, IP, V8::ORri, 2, R).addReg (TmpReg).addImm (((uint32_t) CI->getRawValue ()) & 0x03ff);
+ return;
+ }
+ default:
+ assert (0 && "Can't move this kind of constant");
+ return;
+ }
}
assert (0 && "Can't copy constants into registers yet");