Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def AcoshF128 : Builtin {
}

def AsinF16F128 : Builtin, F16F128MathTemplate {
let Spellings = ["__builtin_asin"];
let Spellings = ["__builtin_asin"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
ConstIgnoringErrnoAndExceptions];
let Prototype = "T(T)";
Expand Down Expand Up @@ -1238,6 +1238,7 @@ def NondetermenisticValue : Builtin {
let Prototype = "void(...)";
}


def ElementwiseAbs : Builtin {
let Spellings = ["__builtin_elementwise_abs"];
let Attributes = [NoThrow, Const, CustomTypeChecking];
Expand Down Expand Up @@ -4968,6 +4969,11 @@ def HLSLGroupMemoryBarrierWithGroupSync: LangBuiltin<"HLSL_LANG"> {
let Attributes = [NoThrow, Const];
let Prototype = "void()";
}
def HLSLOr : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_or"];
let Attributes = [NoThrow, Const];
let Prototype = "void(...)";
}

// Builtins for XRay.
def XRayCustomEvent : Builtin {
Expand Down
19 changes: 19 additions & 0 deletions clang/lib/Headers/hlsl/hlsl_intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ namespace hlsl {
#define _HLSL_16BIT_AVAILABILITY_STAGE(environment, version, stage)
#endif

//===----------------------------------------------------------------------===//
// or builtins
//===----------------------------------------------------------------------===//

/// \fn T or(T x, T y)
/// \brief Returns the bitwise OR of the two input values, \a x and \a y.
/// \param x The first input value and y The second input value.
///
/// \returns The bitwise OR of the two input values.

_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
bool or (bool, bool);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
bool2 or (bool2, bool2);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
bool3 or (bool3, bool3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_or)
bool4 or (bool4, bool4);

//===----------------------------------------------------------------------===//
// abs builtins
//===----------------------------------------------------------------------===//
Expand Down
23 changes: 23 additions & 0 deletions clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,29 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
}
break;
}

case Builtin::BI__builtin_hlsl_or: {
if (SemaRef.checkArgCount(TheCall, 2))
return true;
if (CheckVectorElementCallArgs(&SemaRef, TheCall))
return true;

//Ensure input parameter type is bool
ExprResult A = TheCall->getArg(0);
QualType ArgTyA = A.get()->getType();
ExprResult B = TheCall->getArg(1);
QualType ArgTyB = B.get()->getType();
if (!ArgTyA->isBooleanType() || !ArgTyB->isBooleanType()) {
SemaRef.Diag(TheCall->getArg(0)->getBeginLoc(),
diag::err_typecheck_convert_incompatible)
<< ArgTyA << SemaRef.Context.BoolTy << 1 << 0 << 0;
return true;
}
// Ensure input expr type is a scalar/vector and the same as the return type
if (CheckAnyScalarOrVector(&SemaRef, TheCall, 0))
return true;
break;
}
}
return false;
}
Expand Down