Skip to content

Commit df588be

Browse files
authored
NFC: Fix DXIL op is_const for Barrier and node create handle ops (microsoft#6280)
DXIL operations should use is_const=True for constant arguments. This allows for convenience methods to retrieve the constant value, and could (should, but currently doesn't) result in validation that the argument is constant. `BarrierByNodeRecordHandle` SemanticFlags argument must be constant. `MetadataIdx` for both `createNodeOutputHandle` and `CreateNodeInputRecordHandle` must be constant.
1 parent 64cdb9c commit df588be

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

include/dxc/DXIL/DxilInstructions.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8856,6 +8856,15 @@ struct DxilInst_BarrierByNodeRecordHandle {
88568856
void set_object(llvm::Value *val) { Instr->setOperand(1, val); }
88578857
llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); }
88588858
void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); }
8859+
int32_t get_SemanticFlags_val() const {
8860+
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))
8861+
->getZExtValue());
8862+
}
8863+
void set_SemanticFlags_val(int32_t val) {
8864+
Instr->setOperand(2, llvm::Constant::getIntegerValue(
8865+
llvm::IntegerType::get(Instr->getContext(), 32),
8866+
llvm::APInt(32, (uint64_t)val)));
8867+
}
88598868
};
88608869

88618870
/// This instruction Creates a handle to a NodeOutput
@@ -8883,6 +8892,15 @@ struct DxilInst_CreateNodeOutputHandle {
88838892
// Accessors
88848893
llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); }
88858894
void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); }
8895+
int32_t get_MetadataIdx_val() const {
8896+
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))
8897+
->getZExtValue());
8898+
}
8899+
void set_MetadataIdx_val(int32_t val) {
8900+
Instr->setOperand(1, llvm::Constant::getIntegerValue(
8901+
llvm::IntegerType::get(Instr->getContext(), 32),
8902+
llvm::APInt(32, (uint64_t)val)));
8903+
}
88868904
};
88878905

88888906
/// This instruction returns the handle for the location in the output node
@@ -8972,6 +8990,15 @@ struct DxilInst_CreateNodeInputRecordHandle {
89728990
// Accessors
89738991
llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); }
89748992
void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); }
8993+
int32_t get_MetadataIdx_val() const {
8994+
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))
8995+
->getZExtValue());
8996+
}
8997+
void set_MetadataIdx_val(int32_t val) {
8998+
Instr->setOperand(1, llvm::Constant::getIntegerValue(
8999+
llvm::IntegerType::get(Instr->getContext(), 32),
9000+
llvm::APInt(32, (uint64_t)val)));
9001+
}
89759002
};
89769003

89779004
/// This instruction annotate handle with node record properties

utils/hct/hctdb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,7 +5396,9 @@ def UFI(name, **mappings):
53965396
[
53975397
retvoid_param,
53985398
db_dxil_param(2, "noderecordhandle", "object", "handle of object"),
5399-
db_dxil_param(3, "i32", "SemanticFlags", "semantic flags"),
5399+
db_dxil_param(
5400+
3, "i32", "SemanticFlags", "semantic flags", is_const=True
5401+
),
54005402
],
54015403
)
54025404
next_op_idx += 1
@@ -5409,7 +5411,7 @@ def UFI(name, **mappings):
54095411
"rn",
54105412
[
54115413
db_dxil_param(0, "nodehandle", "output", "handle of object"),
5412-
db_dxil_param(2, "i32", "MetadataIdx", "metadata index"),
5414+
db_dxil_param(2, "i32", "MetadataIdx", "metadata index", is_const=True),
54135415
],
54145416
)
54155417
next_op_idx += 1
@@ -5461,7 +5463,7 @@ def UFI(name, **mappings):
54615463
"rn",
54625464
[
54635465
db_dxil_param(0, "noderecordhandle", "output", "output handle"),
5464-
db_dxil_param(2, "i32", "MetadataIdx", "metadata index"),
5466+
db_dxil_param(2, "i32", "MetadataIdx", "metadata index", is_const=True),
54655467
],
54665468
)
54675469
next_op_idx += 1

0 commit comments

Comments
 (0)