Fix jump tables to match gcc (and the ABI and whatnot)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30594 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Alpha/AlphaISelLowering.cpp b/lib/Target/Alpha/AlphaISelLowering.cpp
index bcd60ed..cbbad53 100644
--- a/lib/Target/Alpha/AlphaISelLowering.cpp
+++ b/lib/Target/Alpha/AlphaISelLowering.cpp
@@ -129,6 +129,8 @@
setOperationAction(ISD::RET, MVT::Other, Custom);
setOperationAction(ISD::JumpTable, MVT::i64, Custom);
+ setOperationAction(ISD::JumpTable, MVT::i32, Custom);
+ setOperationAction(ISD::JumpTableRelocBase, MVT::i64, Custom);
setStackPointerRegisterToSaveRestore(Alpha::R30);
@@ -412,6 +414,8 @@
GP, RA);
case ISD::RET: return LowerRET(Op,DAG, getVRegRA());
case ISD::JumpTable: return LowerJumpTable(Op, DAG);
+ case ISD::JumpTableRelocBase:
+ return DAG.getNode(AlphaISD::GlobalBaseReg, MVT::i64);
case ISD::SINT_TO_FP: {
assert(MVT::i64 == Op.getOperand(0).getValueType() &&
diff --git a/lib/Target/Alpha/AlphaTargetAsmInfo.cpp b/lib/Target/Alpha/AlphaTargetAsmInfo.cpp
index fd77b87..ed8f6cb 100644
--- a/lib/Target/Alpha/AlphaTargetAsmInfo.cpp
+++ b/lib/Target/Alpha/AlphaTargetAsmInfo.cpp
@@ -18,4 +18,6 @@
AlphaTargetAsmInfo::AlphaTargetAsmInfo(const AlphaTargetMachine &TM) {
AlignmentIsInBytes = false;
PrivateGlobalPrefix = "$";
+ JumpTableDirective = ".gprel32";
+ JumpTableTextSection = "\t.section .rodata\n";
}
diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp
index 6204998..a1aab94 100644
--- a/lib/Target/Alpha/AlphaTargetMachine.cpp
+++ b/lib/Target/Alpha/AlphaTargetMachine.cpp
@@ -59,6 +59,7 @@
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
JITInfo(*this),
Subtarget(M, FS) {
+ setRelocationModel(Reloc::PIC_);
}