clang 22.0.0git
DirectX.cpp
Go to the documentation of this file.
1//===--------- DirectX.cpp - Emit LLVM Code for builtins ------------------===//
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// This contains code to emit Builtin calls as LLVM code.
10//
11//===----------------------------------------------------------------------===//
12
13#include "CGHLSLRuntime.h"
14#include "CodeGenFunction.h"
16#include "llvm/IR/Intrinsics.h"
17
18using namespace clang;
19using namespace CodeGen;
20using namespace llvm;
21
23 const CallExpr *E) {
24 switch (BuiltinID) {
25 case DirectX::BI__builtin_dx_dot2add: {
26 Value *A = EmitScalarExpr(E->getArg(0));
27 Value *B = EmitScalarExpr(E->getArg(1));
28 Value *Acc = EmitScalarExpr(E->getArg(2));
29
30 Value *AX = Builder.CreateExtractElement(A, Builder.getSize(0));
31 Value *AY = Builder.CreateExtractElement(A, Builder.getSize(1));
32 Value *BX = Builder.CreateExtractElement(B, Builder.getSize(0));
33 Value *BY = Builder.CreateExtractElement(B, Builder.getSize(1));
34
35 Intrinsic::ID ID = llvm ::Intrinsic::dx_dot2add;
36 return Builder.CreateIntrinsic(
37 /*ReturnType=*/Acc->getType(), ID,
38 ArrayRef<Value *>{Acc, AX, AY, BX, BY}, nullptr, "dx.dot2add");
39 }
40 }
41 return nullptr;
42}
Enumerates target-specific builtins in their own namespaces within namespace clang.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2879
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition Expr.h:3083
llvm::Value * EmitDirectXBuiltinExpr(unsigned BuiltinID, const CallExpr *E)
Definition DirectX.cpp:22
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
QualType getType() const
Definition Value.cpp:237
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30