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)) {}
33 getHLSLType(CodeGenModule &CGM,
const Type *
T,
34 const SmallVector<int32_t> *Packoffsets =
nullptr)
const override;
37llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(
40 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
45 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
46 switch (ResAttrs.ResourceClass) {
47 case llvm::dxil::ResourceClass::UAV:
48 case llvm::dxil::ResourceClass::SRV: {
50 QualType ContainedTy = ResType->getContainedType();
58 ResAttrs.RawBuffer ?
"dx.RawBuffer" :
"dx.TypedBuffer";
59 SmallVector<unsigned, 3> Ints = { ResAttrs.ResourceClass ==
60 llvm::dxil::ResourceClass::UAV,
62 if (!ResAttrs.RawBuffer) {
67 ->getUnqualifiedDesugaredType();
71 return llvm::TargetExtType::get(Ctx, TypeName, {ElemType}, Ints);
73 case llvm::dxil::ResourceClass::CBuffer: {
74 QualType ContainedTy = ResType->getContainedType();
78 llvm::Type *BufferLayoutTy =
79 HLSLBufferLayoutBuilder(CGM,
"dx.Layout")
85 return llvm::TargetExtType::get(Ctx,
"dx.CBuffer", {BufferLayoutTy});
87 case llvm::dxil::ResourceClass::Sampler:
88 llvm_unreachable(
"dx.Sampler handles are not implemented yet");
91 llvm_unreachable(
"Unknown llvm::dxil::ResourceClass enum");
96std::unique_ptr<TargetCodeGenInfo>
98 return std::make_unique<DirectXTargetCodeGenInfo>(CGM.
getTypes());
C Language Family Type Representation.
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 * castAsCanonical() const
Return this type's canonical type cast to the 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)