Skip to content

Commit 6477eb1

Browse files
committed
Address PR review comments.
- Improve comments. - Add fields to DXILType to distinguish types being represented. This allows for cleaner identification of the type.
1 parent e216080 commit 6477eb1

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,17 @@ defset list<DXILOpClass> OpClasses = {
222222

223223
class DXILType : LLVMType<OtherVT> {
224224
let isAny = 1;
225+
int isI16OrI32 = 0;
226+
int isHalfOrFloat = 0;
225227
}
226228

227229
// Concrete records for various overload types supported specifically by
228230
// DXIL Operations.
231+
let isI16OrI32 = 1 in
232+
def llvm_i16ori32_ty : DXILType;
229233

230-
def llvm_i16ori32_ty : DXILType;
231-
def llvm_halforfloat_ty : DXILType;
234+
let isHalfOrFloat = 1 in
235+
def llvm_halforfloat_ty : DXILType;
232236

233237
// Abstraction DXIL Operation to LLVM intrinsic
234238
class DXILOpMappingBase {

llvm/lib/Target/DirectX/DXILOpBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static FunctionCallee getOrCreateDXILOpFunction(dxil::OpCode DXILOp,
257257
// FIXME: find the issue and report error in clang instead of check it in
258258
// backend.
259259
if ((Prop->OverloadTys & (uint16_t)Kind) == 0) {
260-
report_fatal_error("Invalid Overload Type", false);
260+
report_fatal_error("Invalid Overload Type", /* gen_crash_diag=*/false);
261261
}
262262

263263
std::string FnName = constructOverloadName(Kind, OverloadTy, *Prop);

llvm/test/CodeGen/DirectX/frac_error.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s
22

3-
; This test is expected to fail with the following error
3+
; DXIL operation frac does not support double overload type
44
; CHECK: LLVM ERROR: Invalid Overload Type
55

66
; Function Attrs: noinline nounwind optnone

llvm/test/CodeGen/DirectX/sin_error.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s
22

3-
; This test is expected to fail with the following error
3+
; DXIL operation sin does not support double overload type
44
; CHECK: LLVM ERROR: Invalid Overload
55

66
define noundef double @sin_double(double noundef %a) #0 {

llvm/utils/TableGen/DXILEmitter.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,10 @@ static std::string getOverloadKindStr(const Record *R) {
272272
case MVT::Other:
273273
// Handle DXIL-specific overload types
274274
{
275-
auto RetStr =
276-
StringSwitch<std::string>(R->getNameInitAsString())
277-
.Case("llvm_i16ori32_ty", "OverloadKind::I16 | OverloadKind::I32")
278-
.Case("llvm_halforfloat_ty",
279-
"OverloadKind::HALF | OverloadKind::FLOAT")
280-
.Default("");
281-
if (RetStr != "") {
282-
return RetStr;
275+
if (R->getValueAsInt("isHalfOrFloat")) {
276+
return "OverloadKind::HALF | OverloadKind::FLOAT";
277+
} else if (R->getValueAsInt("isI16OrI32")) {
278+
return "OverloadKind::I16 | OverloadKind::I32";
283279
}
284280
}
285281
LLVM_FALLTHROUGH;

0 commit comments

Comments
 (0)