12#include "TargetInfo.h"
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/IR/DerivedTypes.h"
16#include "llvm/IR/Type.h"
29 DirectXTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
30 : TargetCodeGenInfo(std::make_unique<DefaultABIInfo>(CGT)) {}
32 llvm::Type *getHLSLType(CodeGenModule &CGM,
const Type *
T,
33 const CGHLSLOffsetInfo &OffsetInfo)
const override;
35 llvm::Type *getHLSLPadding(CodeGenModule &CGM,
36 CharUnits NumBytes)
const override {
38 return llvm::TargetExtType::get(CGM.
getLLVMContext(),
"dx.Padding", {},
42 bool isHLSLPadding(llvm::Type *Ty)
const override {
43 if (
auto *TET = dyn_cast<llvm::TargetExtType>(Ty))
44 return TET->getName() ==
"dx.Padding";
49llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(
52 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
57 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
58 switch (ResAttrs.ResourceClass) {
59 case llvm::dxil::ResourceClass::UAV:
60 case llvm::dxil::ResourceClass::SRV: {
62 QualType ContainedTy = ResType->getContainedType();
70 ResAttrs.RawBuffer ?
"dx.RawBuffer" :
"dx.TypedBuffer";
71 SmallVector<unsigned, 3> Ints = { ResAttrs.ResourceClass ==
72 llvm::dxil::ResourceClass::UAV,
74 if (!ResAttrs.RawBuffer) {
79 ->getUnqualifiedDesugaredType();
83 return llvm::TargetExtType::get(Ctx, TypeName, {ElemType}, Ints);
85 case llvm::dxil::ResourceClass::CBuffer: {
86 QualType ContainedTy = ResType->getContainedType();
90 llvm::StructType *BufferLayoutTy =
91 HLSLBufferLayoutBuilder(CGM).layOutStruct(
96 return llvm::TargetExtType::get(Ctx,
"dx.CBuffer", {BufferLayoutTy});
98 case llvm::dxil::ResourceClass::Sampler:
99 llvm_unreachable(
"dx.Sampler handles are not implemented yet");
102 llvm_unreachable(
"Unknown llvm::dxil::ResourceClass enum");
107std::unique_ptr<TargetCodeGenInfo>
109 return std::make_unique<DirectXTargetCodeGenInfo>(CGM.
getTypes());
C Language Family Type Representation.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
This class organizes the cross-function state that is used while generating LLVM code.
CodeGenTypes & getTypes()
llvm::LLVMContext & getLLVMContext()
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The base class of the type hierarchy.
bool isStructureType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isVectorType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
std::unique_ptr< TargetCodeGenInfo > createDirectXTargetCodeGenInfo(CodeGenModule &CGM)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
@ Type
The name was classified as a type.
U cast(CodeGen::Address addr)