summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-26 00:43:52 +0000
committerChris Lattner <sabre@nondot.org>2009-06-26 00:43:52 +0000
commit2aaad91bbeb3373fc2bf8fbba79349beda31cfed (patch)
treeb9b271f9a9d054c61ef8ec0a3a01339303a51002 /llvm/lib
parentbb597cdfc26cf528c8e4d60df4aa56b1012f45f0 (diff)
downloadbcm5719-llvm-2aaad91bbeb3373fc2bf8fbba79349beda31cfed.tar.gz
bcm5719-llvm-2aaad91bbeb3373fc2bf8fbba79349beda31cfed.zip
start adding logic in isel to determine asm printer semantics, step N of M.
llvm-svn: 74246
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp25
-rw-r--r--llvm/lib/Target/X86/X86InstrInfo.h12
2 files changed, 29 insertions, 8 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8d0ea662dc0..8d070664b1c 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -4507,14 +4507,25 @@ X86TargetLowering::LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) {
SDValue X86TargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) {
JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
- // FIXME there isn't really any debug into here
- DebugLoc dl = JT->getDebugLoc();
- SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), getPointerTy());
- Result = DAG.getNode(X86ISD::Wrapper, dl, getPointerTy(), Result);
+
+ // In PIC mode (unless we're in RIPRel PIC mode) we add an offset to the
+ // global base reg.
+ unsigned char JTFlag = 0;
+ if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ if (Subtarget->isPICStyleStub())
+ JTFlag = X86II::MO_PIC_BASE_OFFSET;
+ else if (Subtarget->isPICStyleGOT())
+ JTFlag = X86II::MO_GOTOFF;
+ }
+
+ SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), getPointerTy(),
+ JTFlag);
+ DebugLoc DL = JT->getDebugLoc();
+ Result = DAG.getNode(X86ISD::Wrapper, DL, getPointerTy(), Result);
+
// With PIC, the address is actually $g + Offset.
- if (getTargetMachine().getRelocationModel() == Reloc::PIC_ &&
- !Subtarget->isPICStyleRIPRel()) {
- Result = DAG.getNode(ISD::ADD, dl, getPointerTy(),
+ if (JTFlag) {
+ Result = DAG.getNode(ISD::ADD, DL, getPointerTy(),
DAG.getNode(X86ISD::GlobalBaseReg,
DebugLoc::getUnknownLoc(),
getPointerTy()),
diff --git a/llvm/lib/Target/X86/X86InstrInfo.h b/llvm/lib/Target/X86/X86InstrInfo.h
index f8b5e5e53ab..b4ba5f0dc00 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.h
+++ b/llvm/lib/Target/X86/X86InstrInfo.h
@@ -77,9 +77,19 @@ namespace X86II {
/// MO_GOT_ABSOLUTE_ADDRESS - On a symbol operand, this represents a
/// relocation of:
- /// $SYMBOL_LABEL + [. - PICBASELABEL]
+ /// SYMBOL_LABEL + [. - PICBASELABEL]
MO_GOT_ABSOLUTE_ADDRESS = 1,
+ /// MO_PIC_BASE_OFFSET - On a symbol operand this indicates that the
+ /// immediate should get the value of the symbol minus the PIC base label:
+ /// SYMBOL_LABEL - PICBASELABEL
+ MO_PIC_BASE_OFFSET = 2,
+
+ /// MO_GOTOFF - On a symbol operand this indicates that the immediate should
+ /// the offset to the location of the symbol name from the base of the GOT.
+ /// SYMBOL_LABEL @GOTOFF
+ MO_GOTOFF = 3,
+
//===------------------------------------------------------------------===//
// Instruction encodings. These are the standard/most common forms for X86
OpenPOWER on IntegriCloud