Fix for PR1018 - Better support for X86-64 Linux in small code model.

llvm-svn: 32026
This commit is contained in:
Evan Cheng 2006-11-29 23:19:46 +00:00
parent 70c3dd4eff
commit 0b1692216d
3 changed files with 55 additions and 14 deletions

View File

@ -262,7 +262,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
else if (Offset < 0) else if (Offset < 0)
O << Offset; O << Offset;
if (!isCallOp && if (isMemOp &&
Subtarget->is64Bit()) { Subtarget->is64Bit()) {
if (isExt && TM.getRelocationModel() != Reloc::Static) if (isExt && TM.getRelocationModel() != Reloc::Static)
O << "@GOTPCREL"; O << "@GOTPCREL";

View File

@ -590,6 +590,49 @@ bool X86DAGToDAGISel::MatchAddress(SDOperand N, X86ISelAddressMode &AM,
break; break;
} }
case ISD::TargetConstantPool:
if (AM.BaseType == X86ISelAddressMode::RegBase &&
AM.Base.Reg.Val == 0 &&
AM.CP == 0) {
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(N);
AM.CP = CP->getConstVal();
AM.Align = CP->getAlignment();
AM.Disp += CP->getOffset();
return false;
}
break;
case ISD::TargetGlobalAddress:
if (AM.BaseType == X86ISelAddressMode::RegBase &&
AM.Base.Reg.Val == 0 &&
AM.GV == 0) {
GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(N);
AM.GV = G->getGlobal();
AM.Disp += G->getOffset();
return false;
}
break;
case ISD::TargetExternalSymbol:
if (isRoot &&
AM.BaseType == X86ISelAddressMode::RegBase &&
AM.Base.Reg.Val == 0) {
ExternalSymbolSDNode *S = cast<ExternalSymbolSDNode>(N.getOperand(0));
AM.ES = S->getSymbol();
return false;
}
break;
case ISD::TargetJumpTable:
if (isRoot &&
AM.BaseType == X86ISelAddressMode::RegBase &&
AM.Base.Reg.Val == 0) {
JumpTableSDNode *J = cast<JumpTableSDNode>(N.getOperand(0));
AM.JT = J->getIndex();
return false;
}
break;
case X86ISD::Wrapper: case X86ISD::Wrapper:
// If value is available in a register both base and index components have // If value is available in a register both base and index components have
// been picked, we can't fit the result available in the register in the // been picked, we can't fit the result available in the register in the

View File

@ -3829,11 +3829,11 @@ X86TargetLowering::LowerSCALAR_TO_VECTOR(SDOperand Op, SelectionDAG &DAG) {
SDOperand SDOperand
X86TargetLowering::LowerConstantPool(SDOperand Op, SelectionDAG &DAG) { X86TargetLowering::LowerConstantPool(SDOperand Op, SelectionDAG &DAG) {
ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op); ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
SDOperand Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), SDOperand Result = DAG.getTargetConstantPool(CP->getConstVal(),
DAG.getTargetConstantPool(CP->getConstVal(),
getPointerTy(), getPointerTy(),
CP->getAlignment())); CP->getAlignment());
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
// With PIC, the address is actually $g + Offset. // With PIC, the address is actually $g + Offset.
if (!Subtarget->is64Bit() && if (!Subtarget->is64Bit() &&
getTargetMachine().getRelocationModel() == Reloc::PIC_) getTargetMachine().getRelocationModel() == Reloc::PIC_)
@ -3847,10 +3847,9 @@ X86TargetLowering::LowerConstantPool(SDOperand Op, SelectionDAG &DAG) {
SDOperand SDOperand
X86TargetLowering::LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) { X86TargetLowering::LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) {
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal(); GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
SDOperand Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), SDOperand Result = DAG.getTargetGlobalAddress(GV, getPointerTy());
DAG.getTargetGlobalAddress(GV,
getPointerTy()));
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
// With PIC, the address is actually $g + Offset. // With PIC, the address is actually $g + Offset.
if (!Subtarget->is64Bit() && if (!Subtarget->is64Bit() &&
getTargetMachine().getRelocationModel() == Reloc::PIC_) getTargetMachine().getRelocationModel() == Reloc::PIC_)
@ -3866,6 +3865,7 @@ X86TargetLowering::LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) {
Subtarget->GVRequiresExtraLoad(GV, false)) Subtarget->GVRequiresExtraLoad(GV, false))
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0); Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
} else if (Subtarget->GVRequiresExtraLoad(GV, false)) { } else if (Subtarget->GVRequiresExtraLoad(GV, false)) {
Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0); Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
} }
@ -3875,10 +3875,9 @@ X86TargetLowering::LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) {
SDOperand SDOperand
X86TargetLowering::LowerExternalSymbol(SDOperand Op, SelectionDAG &DAG) { X86TargetLowering::LowerExternalSymbol(SDOperand Op, SelectionDAG &DAG) {
const char *Sym = cast<ExternalSymbolSDNode>(Op)->getSymbol(); const char *Sym = cast<ExternalSymbolSDNode>(Op)->getSymbol();
SDOperand Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), SDOperand Result = DAG.getTargetExternalSymbol(Sym, getPointerTy());
DAG.getTargetExternalSymbol(Sym,
getPointerTy()));
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
// With PIC, the address is actually $g + Offset. // With PIC, the address is actually $g + Offset.
if (!Subtarget->is64Bit() && if (!Subtarget->is64Bit() &&
getTargetMachine().getRelocationModel() == Reloc::PIC_) getTargetMachine().getRelocationModel() == Reloc::PIC_)
@ -4244,10 +4243,9 @@ SDOperand X86TargetLowering::LowerBRCOND(SDOperand Op, SelectionDAG &DAG) {
SDOperand X86TargetLowering::LowerJumpTable(SDOperand Op, SelectionDAG &DAG) { SDOperand X86TargetLowering::LowerJumpTable(SDOperand Op, SelectionDAG &DAG) {
JumpTableSDNode *JT = cast<JumpTableSDNode>(Op); JumpTableSDNode *JT = cast<JumpTableSDNode>(Op);
SDOperand Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), SDOperand Result = DAG.getTargetJumpTable(JT->getIndex(), getPointerTy());
DAG.getTargetJumpTable(JT->getIndex(),
getPointerTy()));
if (Subtarget->isTargetDarwin()) { if (Subtarget->isTargetDarwin()) {
Result = DAG.getNode(X86ISD::Wrapper, getPointerTy(), Result);
// With PIC, the address is actually $g + Offset. // With PIC, the address is actually $g + Offset.
if (!Subtarget->is64Bit() && if (!Subtarget->is64Bit() &&
getTargetMachine().getRelocationModel() == Reloc::PIC_) getTargetMachine().getRelocationModel() == Reloc::PIC_)