CGHLSLRuntime.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===----- CGHLSLRuntime.cpp - Interface to HLSL Runtime ----------------===//
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // CGHLSLRuntime.cpp //
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. // This file is distributed under the University of Illinois Open Source //
  7. // License. See LICENSE.TXT for details. //
  8. // //
  9. // This provides a class for HLSL code generation. //
  10. // //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #include "clang/AST/ASTContext.h"
  13. #include "clang/AST/DeclTemplate.h"
  14. #include "clang/AST/HlslTypes.h"
  15. #include "clang/AST/Type.h"
  16. #include "CGHLSLRuntime.h"
  17. using namespace clang;
  18. using namespace CodeGen;
  19. CGHLSLRuntime::~CGHLSLRuntime() {}
  20. bool CGHLSLRuntime::IsHLSLVecMatType(clang::QualType &type) {
  21. return hlsl::IsHLSLVecMatType(type);
  22. }
  23. const clang::ExtVectorType *CGHLSLRuntime::ConvertHLSLVecMatTypeToExtVectorType(
  24. const clang::ASTContext &context, clang::QualType &type) {
  25. return hlsl::ConvertHLSLVecMatTypeToExtVectorType(context, type);
  26. }
  27. QualType CGHLSLRuntime::GetHLSLVecMatElementType(QualType type) {
  28. const Type *Ty = type.getCanonicalType().getTypePtr();
  29. // TODO: check isVecMatrix
  30. const RecordType *RT = cast<RecordType>(Ty);
  31. const ClassTemplateSpecializationDecl *templateDecl =
  32. cast<ClassTemplateSpecializationDecl>(RT->getDecl());
  33. const TemplateArgumentList &argList = templateDecl->getTemplateArgs();
  34. const TemplateArgument &arg0 = argList[0];
  35. return arg0.getAsType();
  36. }