|
12 | 12 |
|
13 | 13 | #include "CGBuiltin.h" |
14 | 14 | #include "CGHLSLRuntime.h" |
15 | | -#include "CodeGenFunction.h" |
16 | 15 |
|
17 | 16 | using namespace clang; |
18 | 17 | using namespace CodeGen; |
@@ -215,43 +214,6 @@ static Intrinsic::ID getWaveActiveMaxIntrinsic(llvm::Triple::ArchType Arch, |
215 | 214 | } |
216 | 215 | } |
217 | 216 |
|
218 | | -// Returns the mangled name for a builtin function that the SPIR-V backend |
219 | | -// will expand into a spec Constant. |
220 | | -static std::string getSpecConstantFunctionName(clang::QualType SpecConstantType, |
221 | | - ASTContext &Context) { |
222 | | - // The parameter types for our conceptual intrinsic function. |
223 | | - QualType ClangParamTypes[] = {Context.IntTy, SpecConstantType}; |
224 | | - |
225 | | - // Create a temporary FunctionDecl for the builtin fuction. It won't be |
226 | | - // added to the AST. |
227 | | - FunctionProtoType::ExtProtoInfo EPI; |
228 | | - QualType FnType = |
229 | | - Context.getFunctionType(SpecConstantType, ClangParamTypes, EPI); |
230 | | - DeclarationName FuncName = &Context.Idents.get("__spirv_SpecConstant"); |
231 | | - FunctionDecl *FnDeclForMangling = FunctionDecl::Create( |
232 | | - Context, Context.getTranslationUnitDecl(), SourceLocation(), |
233 | | - SourceLocation(), FuncName, FnType, /*TSI=*/nullptr, SC_Extern); |
234 | | - |
235 | | - // Attach the created parameter declarations to the function declaration. |
236 | | - SmallVector<ParmVarDecl *, 2> ParamDecls; |
237 | | - for (QualType ParamType : ClangParamTypes) { |
238 | | - ParmVarDecl *PD = ParmVarDecl::Create( |
239 | | - Context, FnDeclForMangling, SourceLocation(), SourceLocation(), |
240 | | - /*IdentifierInfo*/ nullptr, ParamType, /*TSI*/ nullptr, SC_None, |
241 | | - /*DefaultArg*/ nullptr); |
242 | | - ParamDecls.push_back(PD); |
243 | | - } |
244 | | - FnDeclForMangling->setParams(ParamDecls); |
245 | | - |
246 | | - // Get the mangled name. |
247 | | - std::string Name; |
248 | | - llvm::raw_string_ostream MangledNameStream(Name); |
249 | | - MangleContext *Mangler = Context.createMangleContext(); |
250 | | - Mangler->mangleName(FnDeclForMangling, MangledNameStream); |
251 | | - MangledNameStream.flush(); |
252 | | - return Name; |
253 | | -} |
254 | | - |
255 | 217 | Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, |
256 | 218 | const CallExpr *E, |
257 | 219 | ReturnValueSlot ReturnValue) { |
@@ -811,42 +773,6 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, |
811 | 773 | return EmitRuntimeCall( |
812 | 774 | Intrinsic::getOrInsertDeclaration(&CGM.getModule(), ID)); |
813 | 775 | } |
814 | | - case Builtin::BI__builtin_get_spirv_spec_constant_bool: |
815 | | - case Builtin::BI__builtin_get_spirv_spec_constant_short: |
816 | | - case Builtin::BI__builtin_get_spirv_spec_constant_ushort: |
817 | | - case Builtin::BI__builtin_get_spirv_spec_constant_int: |
818 | | - case Builtin::BI__builtin_get_spirv_spec_constant_uint: |
819 | | - case Builtin::BI__builtin_get_spirv_spec_constant_longlong: |
820 | | - case Builtin::BI__builtin_get_spirv_spec_constant_ulonglong: |
821 | | - case Builtin::BI__builtin_get_spirv_spec_constant_half: |
822 | | - case Builtin::BI__builtin_get_spirv_spec_constant_float: |
823 | | - case Builtin::BI__builtin_get_spirv_spec_constant_double: { |
824 | | - llvm::Function *SpecConstantFn = getSpecConstantFunction(E->getType()); |
825 | | - llvm::Value *SpecId = EmitScalarExpr(E->getArg(0)); |
826 | | - llvm::Value *DefaultVal = EmitScalarExpr(E->getArg(1)); |
827 | | - llvm::Value *Args[] = {SpecId, DefaultVal}; |
828 | | - return Builder.CreateCall(SpecConstantFn, Args); |
829 | | - } |
830 | 776 | } |
831 | 777 | return nullptr; |
832 | 778 | } |
833 | | - |
834 | | -llvm::Function *clang::CodeGen::CodeGenFunction::getSpecConstantFunction( |
835 | | - const clang::QualType &SpecConstantType) { |
836 | | - |
837 | | - // Find or create the declaration for the function. |
838 | | - llvm::Module *M = &CGM.getModule(); |
839 | | - std::string MangledName = |
840 | | - getSpecConstantFunctionName(SpecConstantType, getContext()); |
841 | | - llvm::Function *SpecConstantFn = M->getFunction(MangledName); |
842 | | - |
843 | | - if (!SpecConstantFn) { |
844 | | - llvm::Type *IntType = ConvertType(getContext().IntTy); |
845 | | - llvm::Type *RetTy = ConvertType(SpecConstantType); |
846 | | - llvm::Type *ArgTypes[] = {IntType, RetTy}; |
847 | | - llvm::FunctionType *FnTy = llvm::FunctionType::get(RetTy, ArgTypes, false); |
848 | | - SpecConstantFn = llvm::Function::Create( |
849 | | - FnTy, llvm::GlobalValue::ExternalLinkage, MangledName, M); |
850 | | - } |
851 | | - return SpecConstantFn; |
852 | | -} |
0 commit comments