LLVM 20.0.0git
DXILOpBuilder.h
Go to the documentation of this file.
1//===- DXILOpBuilder.h - Helper class for build DIXLOp functions ----------===//
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/// \file This file contains class to help build DXIL op functions.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_LIB_TARGET_DIRECTX_DXILOPBUILDER_H
13#define LLVM_LIB_TARGET_DIRECTX_DXILOPBUILDER_H
14
15#include "DXILConstants.h"
17#include "llvm/IR/IRBuilder.h"
19#include "llvm/Support/Error.h"
21
22namespace llvm {
23class Module;
24class IRBuilderBase;
25class CallInst;
26class Constant;
27class Value;
28class Type;
29class FunctionType;
30
31namespace dxil {
32
34public:
36
37 IRBuilder<> &getIRB() { return IRB; }
38
39 /// Create a call instruction for the given DXIL op. The arguments
40 /// must be valid for an overload of the operation.
42 const Twine &Name = "", Type *RetTy = nullptr);
43
44 /// Try to create a call instruction for the given DXIL op. Fails if the
45 /// overload is invalid.
47 const Twine &Name = "",
48 Type *RetTy = nullptr);
49
50 /// Get a `%dx.types.ResRet` type with the given element type.
51 StructType *getResRetType(Type *ElementTy);
52
53 /// Get the `%dx.types.splitdouble` type.
55
56 /// Get the `%dx.types.Handle` type.
58
59 /// Get a constant `%dx.types.ResBind` value.
60 Constant *getResBind(uint32_t LowerBound, uint32_t UpperBound,
61 uint32_t SpaceID, dxil::ResourceClass RC);
62 /// Get a constant `%dx.types.ResourceProperties` value.
64
65 /// Return the name of the given opcode.
66 static const char *getOpCodeName(dxil::OpCode DXILOp);
67
68private:
69 /// Gets a specific overload type of the function for the given DXIL op. If
70 /// the operation is not overloaded, \c OverloadType may be nullptr.
71 FunctionType *getOpFunctionType(dxil::OpCode OpCode,
72 Type *OverloadType = nullptr);
73
74 Module &M;
75 IRBuilder<> IRB;
76 VersionTuple DXILVersion;
77 Triple::EnvironmentType ShaderStage;
78};
79
80} // namespace dxil
81} // namespace llvm
82
83#endif
RelocType Type
Definition: COFFYAML.cpp:410
return RetTy
std::string Name
Machine Check Debug Module
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
Definition: Constant.h:42
This class represents an Operation in the Expression.
Tagged union holding either a T or a Error.
Definition: Error.h:481
Class to represent function types.
Definition: DerivedTypes.h:105
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2697
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Class to represent struct types.
Definition: DerivedTypes.h:218
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
StructType * getResRetType(Type *ElementTy)
Get a dx.types.ResRet type with the given element type.
StructType * getSplitDoubleType(LLVMContext &Context)
Get the dx.types.splitdouble type.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
CallInst * createOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Create a call instruction for the given DXIL op.
Constant * getResBind(uint32_t LowerBound, uint32_t UpperBound, uint32_t SpaceID, dxil::ResourceClass RC)
Get a constant dx.types.ResBind value.
static const char * getOpCodeName(dxil::OpCode DXILOp)
Return the name of the given opcode.
Constant * getResProps(uint32_t Word0, uint32_t Word1)
Get a constant dx.types.ResourceProperties value.
StructType * getHandleType()
Get the dx.types.Handle type.
ResourceClass
Definition: DXILABI.h:25
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18