Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions llvm/include/llvm/Target/Target.td
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,99 @@ def CONVERGENCECTRL_GLUE : StandardPseudoInstruction {
}
}

/// Allow a target to replace the instruction definition of a
/// StandardPseudoInstruction. A target should only define one
/// instance of this per instruction.
///
/// This is intended to allow targets to specify the register class
/// used for pointers. It should not be used to change the fundamental
/// operand structure (e.g., this should not add or remove operands,
/// or change the operand types).
class TargetSpecializedStandardPseudoInstruction<
StandardPseudoInstruction base_inst> : Instruction {

StandardPseudoInstruction Instruction = base_inst;
let OutOperandList = base_inst.OutOperandList;
let InOperandList = base_inst.InOperandList;

// TODO: Copy everything
let usesCustomInserter = base_inst.usesCustomInserter;
let hasSideEffects = base_inst.hasSideEffects;
let mayLoad = base_inst.mayLoad;
let mayStore = base_inst.mayStore;
let isTerminator = base_inst.isTerminator;
let isBranch = base_inst.isBranch;
let isIndirectBranch = base_inst.isIndirectBranch;
let isEHScopeReturn = base_inst.isEHScopeReturn;
let isReturn = base_inst.isReturn;
let isCall = base_inst.isCall;
let hasCtrlDep = base_inst.hasCtrlDep;
let isReMaterializable = base_inst.isReMaterializable;
let isMeta = base_inst.isMeta;
let Size = base_inst.Size;
let isAsCheapAsAMove = base_inst.isAsCheapAsAMove;
let isPseudo = true;
let hasNoSchedulingInfo = true;
let isNotDuplicable = base_inst.isNotDuplicable;
let isConvergent = base_inst.isConvergent;
let hasExtraSrcRegAllocReq = base_inst.hasExtraSrcRegAllocReq;
let hasExtraDefRegAllocReq = base_inst.hasExtraDefRegAllocReq;
}

// All pseudo instructions which need a pointer register class, which
// should be specialized by a target.
defvar PseudosWithPtrOps = [
LOAD_STACK_GUARD,
PREALLOCATED_ARG,
PATCHABLE_EVENT_CALL,
PATCHABLE_TYPED_EVENT_CALL
];


/// Replace PointerLikeRegClass operands in OperandList with new_rc.
class RemapPointerOperandList<dag OperandList, RegisterClassLike new_rc> {
// Collect the set of names so we can query and rewrite them.
list<string> op_names = !foreach(i, !range(!size(OperandList)),
!getdagname(OperandList, i));

// Beautiful language. This would be a lot easier if !getdagarg
// didn't require a specific type. We can't just collect a list of
// the operand values and reconstruct the dag, since there isn't a
// common base class for all the field kinds used in
// pseudoinstruction definitions; therefore everything must be
// maintained as a dag, so use a foldl. Additionally, ? doesn't
// evaluate as false so we get even more noise.
dag ret =
!foldl(OperandList, op_names, acc, name,
!cond(
!initialized(!getdagarg<PointerLikeRegClass>(OperandList, name))
: !setdagarg(acc, name, new_rc),
!initialized(!getdagarg<unknown_class>(OperandList, name)) : acc,
!initialized(!getdagarg<DAGOperand>(OperandList, name)) : acc
)
);
}

/// Define an override for a pseudoinstruction which uses a pointer
/// register class, specialized to the target's pointer type.
class RemapPointerOperands<StandardPseudoInstruction inst,
RegisterClassLike new_rc> :
TargetSpecializedStandardPseudoInstruction<inst> {
let OutOperandList =
RemapPointerOperandList<inst.OutOperandList, new_rc>.ret;
let InOperandList =
RemapPointerOperandList<inst.InOperandList, new_rc>.ret;
}

/// Helper to replace all pseudoinstructions using pointers to a
/// target register class. Most targets should use this.
multiclass RemapAllTargetPseudoPointerOperands<
RegisterClassLike default_ptr_rc> {
foreach inst = PseudosWithPtrOps in {
def : RemapPointerOperands<inst, default_ptr_rc>;
}
}

// Generic opcodes used in GlobalISel.
include "llvm/Target/GenericOpcodes.td"

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64.td
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ include "AArch64SchedPredExynos.td"
include "AArch64SchedPredNeoverse.td"
include "AArch64Combine.td"

defm : RemapAllTargetPseudoPointerOperands<GPR64sp>;

def AArch64InstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
21 changes: 12 additions & 9 deletions llvm/lib/Target/AMDGPU/R600.td
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@

include "llvm/Target/Target.td"

def R600InstrInfo : InstrInfo {
let guessInstructionProperties = 1;
}

def R600 : Target {
let InstructionSet = R600InstrInfo;
let AllowRegisterRenaming = 1;
}

let Namespace = "R600" in {

foreach Index = 0-15 in {
Expand All @@ -27,6 +18,18 @@ include "R600RegisterInfo.td"

}

defm : RemapAllTargetPseudoPointerOperands<R600_Addr>;

def R600InstrInfo : InstrInfo {
let guessInstructionProperties = 1;
}

def R600 : Target {
let InstructionSet = R600InstrInfo;
let AllowRegisterRenaming = 1;
}


def NullALU : InstrItinClass;
def ALU_NULL : FuncUnit;

Expand Down
11 changes: 11 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -4746,3 +4746,14 @@ def V_ILLEGAL : Enc32, InstSI<(outs), (ins), "v_illegal"> {
let hasSideEffects = 1;
let SubtargetPredicate = isGFX10Plus;
}

defvar VGPR32_Ptr_Opcodes = [LOAD_STACK_GUARD];
defvar VGPR64_Ptr_Opcodes = !listremove(PseudosWithPtrOps, VGPR32_Ptr_Opcodes);

foreach inst = VGPR32_Ptr_Opcodes in {
def : RemapPointerOperands<inst, VGPR_32>;
}

foreach inst = VGPR64_Ptr_Opcodes in {
def : RemapPointerOperands<inst, VReg_64_AlignTarget>;
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/ARM/ARM.td
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ include "ARMSchedule.td"
//===----------------------------------------------------------------------===//

include "ARMInstrInfo.td"

def Thumb1OnlyMode : HwMode<[IsThumb1Only]>;
def arm_ptr_rc : RegClassByHwMode<
[DefaultMode, Thumb1OnlyMode],
[GPR, tGPR]>;

defm : RemapAllTargetPseudoPointerOperands<arm_ptr_rc>;

def ARMInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AVR/AVR.td
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ include "AVRRegisterInfo.td"

include "AVRInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<PTRDISPREGS>;

def AVRInstrInfo : InstrInfo;

//===---------------------------------------------------------------------===//
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Target/BPF/BPF.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ include "BPFCallingConv.td"
include "BPFInstrInfo.td"
include "GISel/BPFRegisterBanks.td"


defm : RemapAllTargetPseudoPointerOperands<GPR>;

def BPFInstrInfo : InstrInfo;

class Proc<string Name, list<SubtargetFeature> Features>
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/CSKY/CSKY.td
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,8 @@ def : CK860V<"ck860fv", NoSchedModel,
// Define the CSKY target.
//===----------------------------------------------------------------------===//

defm : RemapAllTargetPseudoPointerOperands<GPR>;

def CSKYInstrInfo : InstrInfo;


Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/DirectX/DirectX.td
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ include "DXILStubs.td"
// DirectX Subtarget features.
//===----------------------------------------------------------------------===//

defm : RemapAllTargetPseudoPointerOperands<DXILClass>;

def DirectXInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Hexagon/Hexagon.td
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ include "HexagonPatternsV65.td"
include "HexagonDepMappings.td"
include "HexagonIntrinsics.td"

defm : RemapAllTargetPseudoPointerOperands<IntRegs>;

def HexagonInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Lanai/Lanai.td
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ include "LanaiRegisterInfo.td"
include "LanaiCallingConv.td"
include "LanaiInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<GPR>;

def LanaiInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArch.td
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def : ProcessorModel<"la664", NoSchedModel, [Feature64Bit,
// Define the LoongArch target.
//===----------------------------------------------------------------------===//

defm : RemapAllTargetPseudoPointerOperands<GPR>;

def LoongArchInstrInfo : InstrInfo {
let guessInstructionProperties = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/M68k/M68k.td
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ include "GISel/M68kRegisterBanks.td"

include "M68kInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<AR16>;

def M68kInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/MSP430/MSP430.td
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ include "MSP430CallingConv.td"

include "MSP430InstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<GR16>;

def MSP430InstrInfo : InstrInfo;

//===---------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Mips/Mips.td
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ include "MipsScheduleI6400.td"
include "MipsScheduleP5600.td"
include "MipsScheduleGeneric.td"

defm : RemapAllTargetPseudoPointerOperands<mips_ptr_rc>;

def MipsInstrInfo : InstrInfo {
}

Expand Down
10 changes: 10 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTX.td
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ def : Proc<"sm_121", [SM121, PTX88]>;
def : Proc<"sm_121a", [SM121a, PTX88]>;
def : Proc<"sm_121f", [SM121f, PTX88]>;


def Is64Bit : Predicate<"Subtarget->getTargetTriple().getArch() == Triple::nvptx64">;
def NVPTX64 : HwMode<[Is64Bit]>;

def nvptx_ptr_rc : RegClassByHwMode<
[DefaultMode, NVPTX64],
[B32, B64]>;

defm : RemapAllTargetPseudoPointerOperands<nvptx_ptr_rc>;

def NVPTXInstrInfo : InstrInfo {
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/PowerPC/PPC.td
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ def PPCAsmParserVariant : AsmParserVariant {
string BreakCharacters = ".";
}

defm : RemapAllTargetPseudoPointerOperands<ppc_ptr_rc>;

def PPC : Target {
// Information about the instructions.
let InstructionSet = PPCInstrInfo;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/PowerPC/PPCRegisterInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ def PPCRegGxRCNoR0Operand : AsmOperandClass {
let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
}

def ppc_ptr_rc : RegClassByHwMode<
[PPC32, PPC64],
[GPRC, G8RC]>;

def ptr_rc_nor0_by_hwmode : RegClassByHwMode<
[PPC32, PPC64],
[GPRC_NOR0, G8RC_NOX0]>;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/RISCV/RISCV.td
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def RISCVAsmWriter : AsmWriter {
int PassSubtarget = 1;
}

defm : RemapAllTargetPseudoPointerOperands<GPR>;

def RISCV : Target {
let InstructionSet = RISCVInstrInfo;
let AssemblyParsers = [RISCVAsmParser];
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/SPIRV/SPIRV.td
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ include "SPIRVInstrInfo.td"
include "SPIRVCombine.td"
include "SPIRVBuiltins.td"

defm : RemapAllTargetPseudoPointerOperands<pID>;

def SPIRVInstrInfo : InstrInfo;

class Proc<string Name, list<SubtargetFeature> Features>
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Sparc/Sparc.td
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ include "SparcCallingConv.td"
include "SparcSchedule.td"
include "SparcInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<sparc_ptr_rc>;

def SparcInstrInfo : InstrInfo;

def SparcAsmParser : AsmParser {
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/SystemZ/SystemZ.td
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ include "SystemZInstrHFP.td"
include "SystemZInstrDFP.td"
include "SystemZInstrSystem.td"


defm : RemapAllTargetPseudoPointerOperands<ADDR64Bit>;

def SystemZInstrInfo : InstrInfo { let guessInstructionProperties = 0; }

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -98,7 +101,6 @@ def HLASMAsmWriter : AsmWriter {
//===----------------------------------------------------------------------===//
// Top-level target declaration
//===----------------------------------------------------------------------===//

def SystemZ : Target {
let InstructionSet = SystemZInstrInfo;
let AssemblyParsers = [SystemZAsmParser];
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/VE/VE.td
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include "VERegisterInfo.td"
include "VECallingConv.td"
include "VEInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<ve_ptr_rc>;
def VEInstrInfo : InstrInfo {}

def VEAsmParser : AsmParser {
Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/Target/WebAssembly/WebAssembly.td
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ include "WebAssemblyRegisterInfo.td"

include "WebAssemblyInstrInfo.td"

def WASM64 : HwMode<[HasAddr64]>;

def wasm_ptr_rc : RegClassByHwMode<
[DefaultMode, WASM64],
[I32, I64]>;

defm : RemapAllTargetPseudoPointerOperands<wasm_ptr_rc>;

def WebAssemblyInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/X86/X86.td
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,8 @@ include "X86Schedule.td"
include "X86InstrInfo.td"
include "X86SchedPredicates.td"

defm : RemapAllTargetPseudoPointerOperands<x86_ptr_rc>;

def X86InstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/XCore/XCore.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ include "XCoreRegisterInfo.td"
include "XCoreInstrInfo.td"
include "XCoreCallingConv.td"

defm : RemapAllTargetPseudoPointerOperands<GRRegs>;

def XCoreInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Xtensa/Xtensa.td
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ include "XtensaCallingConv.td"

include "XtensaInstrInfo.td"

defm : RemapAllTargetPseudoPointerOperands<AR>;

def XtensaInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
Expand Down
Loading
Loading