[llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Fri Mar 11 09:48:31 PST 2005
Changes in directory llvm/lib/Target/Alpha:
AlphaISelPattern.cpp updated: 1.60 -> 1.61
AlphaInstrInfo.td updated: 1.30 -> 1.31
---
Log message:
remove a pseudo instruction and improve inline constant generation
---
Diffs of the changes: (+29 -6)
AlphaISelPattern.cpp | 32 +++++++++++++++++++++++++++++---
AlphaInstrInfo.td | 3 ---
2 files changed, 29 insertions(+), 6 deletions(-)
Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp
diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.60 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.61
--- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.60 Fri Mar 4 14:09:23 2005
+++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Mar 11 11:48:04 2005
@@ -326,6 +326,25 @@
};
}
+//These describe LDAx
+static const int64_t IMM_LOW = 0xffffffffffff8000LL;
+static const int IMM_HIGH = 0x0000000000007fffLL;
+static const int IMM_MULT = 65536;
+
+static long getUpper16(long l)
+{
+ long y = l / IMM_MULT;
+ if (l % IMM_MULT > IMM_HIGH)
+ ++y;
+ return y;
+}
+
+static long getLower16(long l)
+{
+ long h = getUpper16(l);
+ return l - h * IMM_MULT;
+}
+
static unsigned GetSymVersion(unsigned opcode)
{
switch (opcode) {
@@ -1447,9 +1466,16 @@
case ISD::Constant:
{
- unsigned long val = cast<ConstantSDNode>(N)->getValue();
- if (val < 32000 && (long)val > -32000)
- BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm((long)val);
+ int64_t val = (long)cast<ConstantSDNode>(N)->getValue();
+ if (val <= IMM_HIGH && val >= IMM_LOW) {
+ BuildMI(BB, Alpha::LDA, 2, Result).addImm(val).addReg(Alpha::R31);
+ }
+ else if (val <= (int64_t)IMM_HIGH + (int64_t)IMM_HIGH * (int64_t)IMM_MULT &&
+ val >= (int64_t)IMM_LOW + (int64_t)IMM_LOW * (int64_t)IMM_MULT) {
+ Tmp1 = MakeReg(MVT::i64);
+ BuildMI(BB, Alpha::LDAH, 2, Tmp1).addImm(getUpper16(val)).addReg(Alpha::R31);
+ BuildMI(BB, Alpha::LDA, 2, Result).addImm(getLower16(val)).addReg(Tmp1);
+ }
else {
MachineConstantPool *CP = BB->getParent()->getConstantPool();
ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val);
Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td
diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.30 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.31
--- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.30 Wed Mar 9 14:48:23 2005
+++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Fri Mar 11 11:48:05 2005
@@ -53,9 +53,6 @@
let isReturn = 1, isTerminator = 1 in
def RETURN : PseudoInstAlpha<(ops ), "ret $$31,($$26),1">; //Return from subroutine
-let Uses = [R29], Defs = [R28] in
- def LOAD_IMM : PseudoInstAlpha<(ops GPRC:$RC, s64imm:$IMM), "ldiq $RC,$IMM">; //Load Immediate Quadword
-
let Uses = [R29], Defs = [R28] in {
def LOAD_ADDR : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "lda $RA,$DISP">; //Load address
def LDQ_SYM : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "ldq $RA,$DISP">; //Load quadword
More information about the llvm-commits
mailing list