LLVM 23.0.0git
SPIRVISelLowering.h
Go to the documentation of this file.
1//===-- SPIRVISelLowering.h - SPIR-V DAG Lowering Interface -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the interfaces that SPIR-V uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H
15#define LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H
16
17#include "SPIRVGlobalRegistry.h"
19
20namespace llvm {
21class SPIRVSubtarget;
22
24 const SPIRVSubtarget &STI;
25
26public:
27 explicit SPIRVTargetLowering(const TargetMachine &TM,
28 const SPIRVSubtarget &ST);
29
30 // Stop IRTranslator breaking up FMA instrs to preserve types information.
32 EVT) const override {
33 return true;
34 }
35
36 // prevent creation of jump tables
37 bool areJTsAllowed(const Function *) const override { return false; }
38
39 // This is to prevent sexts of non-i64 vector indices which are generated
40 // within general IRTranslator hence type generation for it is omitted.
41 unsigned getVectorIdxWidth(const DataLayout &DL) const override { return 32; }
44 EVT VT) const override;
46 EVT VT) const override;
48 const CallBase &I, MachineFunction &MF,
49 unsigned Intrinsic) const override;
50
51 ConstraintType getConstraintType(StringRef Constraint) const override;
52
53 std::pair<unsigned, const TargetRegisterClass *>
55 StringRef Constraint, MVT VT) const override;
56 unsigned
58 std::optional<MVT> RegisterVT = std::nullopt) const override {
59 return 1;
60 }
61
62 // Call the default implementation and finalize target lowering by inserting
63 // extra instructions required to preserve validity of SPIR-V code imposed by
64 // the standard.
65 void finalizeLowering(MachineFunction &MF) const override;
66
68 EVT ConditionVT) const override {
69 return ConditionVT.getSimpleVT();
70 }
71
72 bool enforcePtrTypeCompatibility(MachineInstr &I, unsigned PtrOpIdx,
73 unsigned OpIdx) const;
75 SPIRVTypeInst NewResultType) const;
76
78 shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override;
80 shouldCastAtomicRMWIInIR(AtomicRMWInst *RMWI) const override;
83
85 return false;
86 }
87};
88} // namespace llvm
89
90#endif // LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
MachineInstr unsigned OpIdx
This file describes how to lower LLVM code to machine code.
an instruction that atomically reads a memory location, combines it with another value,...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
An instruction for reading from memory.
Machine Value Type.
Representation of each machine instruction.
MVT getPreferredSwitchConditionType(LLVMContext &Context, EVT ConditionVT) const override
Returns preferred type for switch condition.
AtomicExpansionKind shouldCastAtomicRMWIInIR(AtomicRMWInst *RMWI) const override
Returns how the given atomic atomicrmw should be cast by the IR-level AtomicExpand pass.
bool areJTsAllowed(const Function *) const override
Return true if lowering to a jump table is allowed.
AtomicExpansionKind shouldCastAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be cast by the IR-level AtomicExpand pass.
bool enforcePtrTypeCompatibility(MachineInstr &I, unsigned PtrOpIdx, unsigned OpIdx) const
unsigned getVectorIdxWidth(const DataLayout &DL) const override
Returns the type to be used for the index operand vector operations.
unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT=std::nullopt) const override
Return the number of registers that this ValueType will eventually require.
unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain targets require unusual breakdowns of certain types.
bool shouldIssueAtomicLoadForAtomicEmulationLoop() const override
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
void finalizeLowering(MachineFunction &MF) const override
Execute target specific actions to finalize target lowering.
void getTgtMemIntrinsic(SmallVectorImpl< IntrinsicInfo > &Infos, const CallBase &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
bool insertLogicalCopyOnResult(MachineInstr &I, SPIRVTypeInst NewResultType) const
AtomicExpansionKind shouldCastAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be cast by the IR-level AtomicExpand pass into.
SPIRVTargetLowering(const TargetMachine &TM, const SPIRVSubtarget &ST)
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, EVT) const override
Return true if an FMA operation is faster than a pair of fmul and fadd instructions.
ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
Extended Value Type.
Definition ValueTypes.h:35
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition ValueTypes.h:339