mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-12-19 11:23:32 +00:00
Use MCSymbols for FastISel.
The summary is that it moves the mangling earlier and replaces a few calls to .addExternalSymbol with addSym. I originally wanted to replace all the uses of addExternalSymbol with addSym, but noticed it was a lot of work and doesn't need to be done all at once. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240395 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
using namespace llvm;
|
||||
|
||||
@@ -3070,9 +3071,9 @@ bool AArch64FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
bool IsTailCall = CLI.IsTailCall;
|
||||
bool IsVarArg = CLI.IsVarArg;
|
||||
const Value *Callee = CLI.Callee;
|
||||
const char *SymName = CLI.SymName;
|
||||
MCSymbol *Symbol = CLI.Symbol;
|
||||
|
||||
if (!Callee && !SymName)
|
||||
if (!Callee && !Symbol)
|
||||
return false;
|
||||
|
||||
// Allow SelectionDAG isel to handle tail calls.
|
||||
@@ -3134,8 +3135,8 @@ bool AArch64FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
if (CM == CodeModel::Small) {
|
||||
const MCInstrDesc &II = TII.get(Addr.getReg() ? AArch64::BLR : AArch64::BL);
|
||||
MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II);
|
||||
if (SymName)
|
||||
MIB.addExternalSymbol(SymName, 0);
|
||||
if (Symbol)
|
||||
MIB.addSym(Symbol, 0);
|
||||
else if (Addr.getGlobalValue())
|
||||
MIB.addGlobalAddress(Addr.getGlobalValue(), 0, 0);
|
||||
else if (Addr.getReg()) {
|
||||
@@ -3145,18 +3146,18 @@ bool AArch64FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
return false;
|
||||
} else {
|
||||
unsigned CallReg = 0;
|
||||
if (SymName) {
|
||||
if (Symbol) {
|
||||
unsigned ADRPReg = createResultReg(&AArch64::GPR64commonRegClass);
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::ADRP),
|
||||
ADRPReg)
|
||||
.addExternalSymbol(SymName, AArch64II::MO_GOT | AArch64II::MO_PAGE);
|
||||
.addSym(Symbol, AArch64II::MO_GOT | AArch64II::MO_PAGE);
|
||||
|
||||
CallReg = createResultReg(&AArch64::GPR64RegClass);
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::LDRXui),
|
||||
CallReg)
|
||||
.addReg(ADRPReg)
|
||||
.addExternalSymbol(SymName, AArch64II::MO_GOT | AArch64II::MO_PAGEOFF |
|
||||
AArch64II::MO_NC);
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
|
||||
TII.get(AArch64::LDRXui), CallReg)
|
||||
.addReg(ADRPReg)
|
||||
.addSym(Symbol,
|
||||
AArch64II::MO_GOT | AArch64II::MO_PAGEOFF | AArch64II::MO_NC);
|
||||
} else if (Addr.getGlobalValue())
|
||||
CallReg = materializeGV(Addr.getGlobalValue());
|
||||
else if (Addr.getReg())
|
||||
@@ -3460,7 +3461,8 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
|
||||
}
|
||||
|
||||
CallLoweringInfo CLI;
|
||||
CLI.setCallee(TLI.getLibcallCallingConv(LC), II->getType(),
|
||||
MCContext &Ctx = MF->getContext();
|
||||
CLI.setCallee(DL, Ctx, TLI.getLibcallCallingConv(LC), II->getType(),
|
||||
TLI.getLibcallName(LC), std::move(Args));
|
||||
if (!lowerCallTo(CLI))
|
||||
return false;
|
||||
@@ -4734,7 +4736,8 @@ bool AArch64FastISel::selectFRem(const Instruction *I) {
|
||||
}
|
||||
|
||||
CallLoweringInfo CLI;
|
||||
CLI.setCallee(TLI.getLibcallCallingConv(LC), I->getType(),
|
||||
MCContext &Ctx = MF->getContext();
|
||||
CLI.setCallee(DL, Ctx, TLI.getLibcallCallingConv(LC), I->getType(),
|
||||
TLI.getLibcallName(LC), std::move(Args));
|
||||
if (!lowerCallTo(CLI))
|
||||
return false;
|
||||
|
||||
@@ -187,6 +187,9 @@ bool AArch64MCInstLower::lowerOperand(const MachineOperand &MO,
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
|
||||
break;
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
MCOp = LowerSymbolOperand(MO, MO.getMCSymbol());
|
||||
break;
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
MCOp = LowerSymbolOperand(MO, Printer.GetJTISymbol(MO.getIndex()));
|
||||
break;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "llvm/IR/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/IR/GlobalAlias.h"
|
||||
#include "llvm/IR/GlobalVariable.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
|
||||
using namespace llvm;
|
||||
@@ -143,7 +144,7 @@ private:
|
||||
unsigned materializeGV(const GlobalValue *GV, MVT VT);
|
||||
unsigned materializeInt(const Constant *C, MVT VT);
|
||||
unsigned materialize32BitInt(int64_t Imm, const TargetRegisterClass *RC);
|
||||
unsigned materializeExternalCallSym(const char *SynName);
|
||||
unsigned materializeExternalCallSym(MCSymbol *Syn);
|
||||
|
||||
MachineInstrBuilder emitInst(unsigned Opc) {
|
||||
return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc));
|
||||
@@ -369,12 +370,12 @@ unsigned MipsFastISel::materializeGV(const GlobalValue *GV, MVT VT) {
|
||||
return DestReg;
|
||||
}
|
||||
|
||||
unsigned MipsFastISel::materializeExternalCallSym(const char *SymName) {
|
||||
unsigned MipsFastISel::materializeExternalCallSym(MCSymbol *Sym) {
|
||||
const TargetRegisterClass *RC = &Mips::GPR32RegClass;
|
||||
unsigned DestReg = createResultReg(RC);
|
||||
emitInst(Mips::LW, DestReg)
|
||||
.addReg(MFI->getGlobalBaseReg())
|
||||
.addExternalSymbol(SymName, MipsII::MO_GOT);
|
||||
.addSym(Sym, MipsII::MO_GOT);
|
||||
return DestReg;
|
||||
}
|
||||
|
||||
@@ -1234,7 +1235,7 @@ bool MipsFastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
bool IsTailCall = CLI.IsTailCall;
|
||||
bool IsVarArg = CLI.IsVarArg;
|
||||
const Value *Callee = CLI.Callee;
|
||||
const char *SymName = CLI.SymName;
|
||||
MCSymbol *Symbol = CLI.Symbol;
|
||||
|
||||
// Allow SelectionDAG isel to handle tail calls.
|
||||
if (IsTailCall)
|
||||
@@ -1286,8 +1287,8 @@ bool MipsFastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
|
||||
// Issue the call.
|
||||
unsigned DestAddress;
|
||||
if (SymName)
|
||||
DestAddress = materializeExternalCallSym(SymName);
|
||||
if (Symbol)
|
||||
DestAddress = materializeExternalCallSym(Symbol);
|
||||
else
|
||||
DestAddress = materializeGV(Addr.getGlobalValue(), MVT::i32);
|
||||
emitInst(TargetOpcode::COPY, Mips::T9).addReg(DestAddress);
|
||||
|
||||
@@ -88,6 +88,11 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||
Offset += MO.getOffset();
|
||||
break;
|
||||
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
Symbol = MO.getMCSymbol();
|
||||
Offset += MO.getOffset();
|
||||
break;
|
||||
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
Symbol = AsmPrinter.GetJTISymbol(MO.getIndex());
|
||||
break;
|
||||
@@ -141,6 +146,7 @@ MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
case MachineOperand::MO_ExternalSymbol:
|
||||
case MachineOperand::MO_MCSymbol:
|
||||
case MachineOperand::MO_JumpTableIndex:
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
|
||||
@@ -1448,9 +1448,9 @@ bool PPCFastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
bool IsTailCall = CLI.IsTailCall;
|
||||
bool IsVarArg = CLI.IsVarArg;
|
||||
const Value *Callee = CLI.Callee;
|
||||
const char *SymName = CLI.SymName;
|
||||
const MCSymbol *Symbol = CLI.Symbol;
|
||||
|
||||
if (!Callee && !SymName)
|
||||
if (!Callee && !Symbol)
|
||||
return false;
|
||||
|
||||
// Allow SelectionDAG isel to handle tail calls.
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
using namespace llvm;
|
||||
@@ -2821,7 +2822,7 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
bool &IsTailCall = CLI.IsTailCall;
|
||||
bool IsVarArg = CLI.IsVarArg;
|
||||
const Value *Callee = CLI.Callee;
|
||||
const char *SymName = CLI.SymName;
|
||||
MCSymbol *Symbol = CLI.Symbol;
|
||||
|
||||
bool Is64Bit = Subtarget->is64Bit();
|
||||
bool IsWin64 = Subtarget->isCallingConvWin64(CC);
|
||||
@@ -3117,8 +3118,8 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
|
||||
}
|
||||
|
||||
MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(CallOpc));
|
||||
if (SymName)
|
||||
MIB.addExternalSymbol(SymName, OpFlags);
|
||||
if (Symbol)
|
||||
MIB.addSym(Symbol, OpFlags);
|
||||
else
|
||||
MIB.addGlobalAddress(GV, 0, OpFlags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user