LLVM 22.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#include <set>
20
21namespace llvm {
22class SPIRVSubtarget;
23
25 const SPIRVSubtarget &STI;
26
27 // Record of already processed machine functions
28 mutable std::set<const MachineFunction *> ProcessedMF;
29
30public:
31 explicit SPIRVTargetLowering(const TargetMachine &TM,
32 const SPIRVSubtarget &ST);
33
34 // Stop IRTranslator breaking up FMA instrs to preserve types information.
36 EVT) const override {
37 return true;
38 }
39
40 // prevent creation of jump tables
41 bool areJTsAllowed(const Function *) const override { return false; }
42
43 // This is to prevent sexts of non-i64 vector indices which are generated
44 // within general IRTranslator hence type generation for it is omitted.
45 unsigned getVectorIdxWidth(const DataLayout &DL) const override { return 32; }
48 EVT VT) const override;
50 EVT VT) const override;
51 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
53 unsigned Intrinsic) const override;
54
55 std::pair<unsigned, const TargetRegisterClass *>
57 StringRef Constraint, MVT VT) const override;
58 unsigned
60 std::optional<MVT> RegisterVT = std::nullopt) const override {
61 return 1;
62 }
63
64 // Call the default implementation and finalize target lowering by inserting
65 // extra instructions required to preserve validity of SPIR-V code imposed by
66 // the standard.
67 void finalizeLowering(MachineFunction &MF) const override;
68
70 EVT ConditionVT) const override {
71 return ConditionVT.getSimpleVT();
72 }
73
74 bool enforcePtrTypeCompatibility(MachineInstr &I, unsigned PtrOpIdx,
75 unsigned OpIdx) const;
77 SPIRVType *NewResultType) const;
78};
79} // namespace llvm
80
81#endif // LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
Definition CSEInfo.cpp:27
#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.
This class represents a function call, abstracting a target machine's calling convention.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Machine Value Type.
Representation of each machine instruction.
MVT getPreferredSwitchConditionType(LLVMContext &Context, EVT ConditionVT) const override
Returns preferred type for switch condition.
bool areJTsAllowed(const Function *) const override
Return true if lowering to a jump table is allowed.
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.
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...
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &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...
void finalizeLowering(MachineFunction &MF) const override
Execute target specific actions to finalize target lowering.
bool insertLogicalCopyOnResult(MachineInstr &I, SPIRVType *NewResultType) const
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.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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.
const MachineInstr SPIRVType
Extended Value Type.
Definition ValueTypes.h:35
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition ValueTypes.h:316