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"
18#include "llvm/Support/Error.h"
19
20namespace llvm {
21class Module;
22class IRBuilderBase;
23class CallInst;
24class Value;
25class Type;
26class FunctionType;
27
28namespace dxil {
29
31public:
33
34 /// Create a call instruction for the given DXIL op. The arguments
35 /// must be valid for an overload of the operation.
37 Type *RetTy = nullptr);
38
39#define DXIL_OPCODE(Op, Name) \
40 CallInst *create##Name##Op(ArrayRef<Value *> &Args, Type *RetTy = nullptr) { \
41 return createOp(dxil::OpCode(Op), Args, RetTy); \
42 }
43#include "DXILOperation.inc"
44
45 /// Try to create a call instruction for the given DXIL op. Fails if the
46 /// overload is invalid.
48 Type *RetTy = nullptr);
49#define DXIL_OPCODE(Op, Name) \
50 Expected<CallInst *> tryCreate##Name##Op(ArrayRef<Value *> &Args, \
51 Type *RetTy = nullptr) { \
52 return tryCreateOp(dxil::OpCode(Op), Args, RetTy); \
53 }
54#include "DXILOperation.inc"
55
56 /// Return the name of the given opcode.
57 static const char *getOpCodeName(dxil::OpCode DXILOp);
58
59private:
60 /// Gets a specific overload type of the function for the given DXIL op. If
61 /// the operation is not overloaded, \c OverloadType may be nullptr.
62 FunctionType *getOpFunctionType(dxil::OpCode OpCode,
63 Type *OverloadType = nullptr);
64
65 Module &M;
66 IRBuilderBase &B;
67 VersionTuple DXILVersion;
68 Triple::EnvironmentType ShaderStage;
69};
70
71} // namespace dxil
72} // namespace llvm
73
74#endif
RelocType Type
Definition: COFFYAML.cpp:391
return RetTy
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 class represents an Operation in the Expression.
Tagged union holding either a T or a Error.
Definition: Error.h:481
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:91
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
CallInst * createOp(dxil::OpCode Op, ArrayRef< Value * > &Args, Type *RetTy=nullptr)
Create a call instruction for the given DXIL op.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
static const char * getOpCodeName(dxil::OpCode DXILOp)
Return the name of the given opcode.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18