aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2006-09-24 19:45:58 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2006-09-24 19:45:58 +0000
commitbeec30eaf301bd6882cd06800b5175b94f033f9d (patch)
treec19a2eaf2fc2c57289099d0a93c8f5166b7564ea /lib/CodeGen
parentb08659d2e55562a94a92593cc51f35f2229e65f3 (diff)
Add support for other relocation bases to jump tables, as well as custom asm directives
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30593 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp11
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp11
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp3
3 files changed, 21 insertions, 4 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index f6b4bfcbfe..bcdb393c23 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -187,7 +187,10 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
// JTEntryDirective is a string to print sizeof(ptr) for non-PIC jump tables,
// and 32 bits for PIC since PIC jump table entries are differences, not
// pointers to blocks.
- const char *JTEntryDirective = TAI->getData32bitsDirective();
+ // Use the architecture specific relocation directive, if it is set
+ const char *JTEntryDirective = TAI->getJumpTableDirective();
+ if (!JTEntryDirective)
+ JTEntryDirective = TAI->getData32bitsDirective();
// Pick the directive to use to print the jump table entries, and switch to
// the appropriate section.
@@ -227,8 +230,10 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
<< '_' << i << "_set_" << JTBBs[ii]->getNumber();
} else if (TM.getRelocationModel() == Reloc::PIC_) {
printBasicBlockLabel(JTBBs[ii], false, false);
- O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
- << getFunctionNumber() << '_' << i;
+ //If the arch uses custom Jump Table directives, don't calc relative to JT
+ if (!TAI->getJumpTableDirective())
+ O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
+ << getFunctionNumber() << '_' << i;
} else {
printBasicBlockLabel(JTBBs[ii], false, false);
}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index cb8588c031..9507e4be84 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -558,6 +558,17 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
#endif
assert(0 && "Do not know how to legalize this operator!");
abort();
+ case ISD::JumpTableRelocBase:
+ switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) {
+ case TargetLowering::Custom:
+ Tmp1 = TLI.LowerOperation(Op, DAG);
+ if (Tmp1.Val) Result = Tmp1;
+ break;
+ default:
+ Result = LegalizeOp(Node->getOperand(0));
+ break;
+ }
+ break;
case ISD::GlobalAddress:
case ISD::ExternalSymbol:
case ISD::ConstantPool:
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index cf26eb2951..27a45a1d52 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -868,8 +868,9 @@ void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) {
SDOperand LD = DAG.getLoad(isPIC ? MVT::i32 : PTy, Copy.getValue(1), ADD,
DAG.getSrcValue(0));
if (isPIC) {
+ SDOperand Reloc = DAG.getNode(ISD::JumpTableRelocBase, PTy, TAB);
ADD = DAG.getNode(ISD::ADD, PTy,
- ((PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD), TAB);
+ ((PTy != MVT::i32) ? DAG.getNode(ISD::SIGN_EXTEND, PTy, LD) : LD), Reloc);
DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), ADD));
} else {
DAG.setRoot(DAG.getNode(ISD::BRIND, MVT::Other, LD.getValue(1), LD));