mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Refactored *GVRequiresExtraLoad() to Subtarget method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31887 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -35,8 +35,6 @@
|
|||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static bool WindowsGVRequiresExtraLoad(GlobalValue *GV);
|
|
||||||
|
|
||||||
// FIXME: temporary.
|
// FIXME: temporary.
|
||||||
static cl::opt<bool> EnableFastCC("enable-x86-fastcc", cl::Hidden,
|
static cl::opt<bool> EnableFastCC("enable-x86-fastcc", cl::Hidden,
|
||||||
cl::desc("Enable fastcc on X86"));
|
cl::desc("Enable fastcc on X86"));
|
||||||
@ -655,8 +653,7 @@ SDOperand X86TargetLowering::LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG) {
|
|||||||
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
||||||
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
||||||
// We should use extra load for direct calls to dllimported functions
|
// We should use extra load for direct calls to dllimported functions
|
||||||
if (!((Subtarget->isTargetCygwin() || Subtarget->isTargetWindows()) &&
|
if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(), true))
|
||||||
WindowsGVRequiresExtraLoad(G->getGlobal())))
|
|
||||||
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
||||||
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
||||||
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
||||||
@ -1193,8 +1190,7 @@ X86TargetLowering::LowerX86_64CCCCallTo(SDOperand Op, SelectionDAG &DAG) {
|
|||||||
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
||||||
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
||||||
// We should use extra load for direct calls to dllimported functions
|
// We should use extra load for direct calls to dllimported functions
|
||||||
if (!((Subtarget->isTargetCygwin() || Subtarget->isTargetWindows()) &&
|
if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(), true))
|
||||||
WindowsGVRequiresExtraLoad(G->getGlobal())))
|
|
||||||
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
||||||
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
||||||
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
||||||
@ -1691,8 +1687,7 @@ SDOperand X86TargetLowering::LowerFastCCCallTo(SDOperand Op, SelectionDAG &DAG,
|
|||||||
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
||||||
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
||||||
// We should use extra load for direct calls to dllimported functions
|
// We should use extra load for direct calls to dllimported functions
|
||||||
if (!((Subtarget->isTargetCygwin() || Subtarget->isTargetWindows()) &&
|
if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(), true))
|
||||||
WindowsGVRequiresExtraLoad(G->getGlobal())))
|
|
||||||
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
||||||
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
||||||
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
||||||
@ -1990,8 +1985,7 @@ SDOperand X86TargetLowering::LowerStdCallCCCallTo(SDOperand Op,
|
|||||||
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
// turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
|
||||||
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
|
||||||
// We should use extra load for direct calls to dllimported functions
|
// We should use extra load for direct calls to dllimported functions
|
||||||
if (!((Subtarget->isTargetCygwin() || Subtarget->isTargetWindows()) &&
|
if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(), true))
|
||||||
WindowsGVRequiresExtraLoad(G->getGlobal())))
|
|
||||||
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
|
||||||
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee))
|
||||||
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
|
||||||
@ -2426,25 +2420,6 @@ static bool hasFPCMov(unsigned X86CC) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DarwinGVRequiresExtraLoad - true if accessing the GV requires an extra
|
|
||||||
/// load. For Darwin, external and weak symbols are indirect, loading the value
|
|
||||||
/// at address GV rather then the value of GV itself. This means that the
|
|
||||||
/// GlobalAddress must be in the base or index register of the address, not the
|
|
||||||
/// GV offset field.
|
|
||||||
static bool DarwinGVRequiresExtraLoad(GlobalValue *GV) {
|
|
||||||
return (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
|
||||||
(GV->isExternal() && !GV->hasNotBeenReadFromBytecode()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// WindowsGVRequiresExtraLoad - true if accessing the GV requires an extra
|
|
||||||
/// load. For Windows, dllimported symbols are indirect, loading the value at
|
|
||||||
/// address GV rather then the value of GV itself. This means that the
|
|
||||||
/// GlobalAddress must be in the base or index register of the address, not the
|
|
||||||
/// GV offset field.
|
|
||||||
static bool WindowsGVRequiresExtraLoad(GlobalValue *GV) {
|
|
||||||
return (GV->hasDLLImportLinkage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isUndefOrInRange - Op is either an undef node or a ConstantSDNode. Return
|
/// isUndefOrInRange - Op is either an undef node or a ConstantSDNode. Return
|
||||||
/// true if Op is undef or if its value falls within the specified range (L, H].
|
/// true if Op is undef or if its value falls within the specified range (L, H].
|
||||||
static bool isUndefOrInRange(SDOperand Op, unsigned Low, unsigned Hi) {
|
static bool isUndefOrInRange(SDOperand Op, unsigned Low, unsigned Hi) {
|
||||||
@ -3888,15 +3863,12 @@ X86TargetLowering::LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) {
|
|||||||
// the GlobalAddress must be in the base or index register of the address,
|
// the GlobalAddress must be in the base or index register of the address,
|
||||||
// not the GV offset field.
|
// not the GV offset field.
|
||||||
if (getTargetMachine().getRelocationModel() != Reloc::Static &&
|
if (getTargetMachine().getRelocationModel() != Reloc::Static &&
|
||||||
DarwinGVRequiresExtraLoad(GV))
|
Subtarget->GVRequiresExtraLoad(GV, false))
|
||||||
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
|
|
||||||
} else if (Subtarget->isTargetCygwin() || Subtarget->isTargetWindows()) {
|
|
||||||
// FIXME: What about PIC?
|
|
||||||
if (WindowsGVRequiresExtraLoad(GV))
|
|
||||||
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
|
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
|
||||||
|
} else if (Subtarget->GVRequiresExtraLoad(GV, false)) {
|
||||||
|
Result = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), Result, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5020,7 +4992,7 @@ bool X86TargetLowering::isLegalAddressImmediate(GlobalValue *GV) const {
|
|||||||
if (RModel == Reloc::Static)
|
if (RModel == Reloc::Static)
|
||||||
return true;
|
return true;
|
||||||
else if (RModel == Reloc::DynamicNoPIC)
|
else if (RModel == Reloc::DynamicNoPIC)
|
||||||
return !DarwinGVRequiresExtraLoad(GV);
|
return !(Subtarget->GVRequiresExtraLoad(GV, false));
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
@ -5647,4 +5619,3 @@ X86TargetLowering::getRegForInlineAsmConstraint(const std::string &Constraint,
|
|||||||
|
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef X86SUBTARGET_H
|
#ifndef X86SUBTARGET_H
|
||||||
#define X86SUBTARGET_H
|
#define X86SUBTARGET_H
|
||||||
|
|
||||||
|
#include "llvm/GlobalValue.h"
|
||||||
#include "llvm/Target/TargetSubtarget.h"
|
#include "llvm/Target/TargetSubtarget.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -105,6 +106,23 @@ public:
|
|||||||
bool isTargetELF() const { return TargetType == isELF; }
|
bool isTargetELF() const { return TargetType == isELF; }
|
||||||
bool isTargetWindows() const { return TargetType == isWindows; }
|
bool isTargetWindows() const { return TargetType == isWindows; }
|
||||||
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
bool isTargetCygwin() const { return TargetType == isCygwin; }
|
||||||
|
|
||||||
|
/// True if accessing the GV requires an extra load. For Windows, dllimported
|
||||||
|
/// symbols are indirect, loading the value at address GV rather then the
|
||||||
|
/// value of GV itself. This means that the GlobalAddress must be in the base
|
||||||
|
/// or index register of the address, not the GV offset field.
|
||||||
|
bool GVRequiresExtraLoad(const GlobalValue* GV, bool isDirectCall) const
|
||||||
|
{
|
||||||
|
if (isTargetDarwin()) {
|
||||||
|
return (!isDirectCall &&
|
||||||
|
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
||||||
|
(GV->isExternal() && !GV->hasNotBeenReadFromBytecode())));
|
||||||
|
} else if (isTargetCygwin() || isTargetWindows()) {
|
||||||
|
return (GV->hasDLLImportLinkage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace X86 {
|
namespace X86 {
|
||||||
|
Reference in New Issue
Block a user