Skip to content

Commit

Permalink
NFC: Fix DXIL op is_const for Barrier and node create handle ops (#6280)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tex3d authored Feb 15, 2024
1 parent 64cdb9c commit df588be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
27 changes: 27 additions & 0 deletions include/dxc/DXIL/DxilInstructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8856,6 +8856,15 @@ struct DxilInst_BarrierByNodeRecordHandle {
void set_object(llvm::Value *val) { Instr->setOperand(1, val); }
llvm::Value *get_SemanticFlags() const { return Instr->getOperand(2); }
void set_SemanticFlags(llvm::Value *val) { Instr->setOperand(2, val); }
int32_t get_SemanticFlags_val() const {
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(2))
->getZExtValue());
}
void set_SemanticFlags_val(int32_t val) {
Instr->setOperand(2, llvm::Constant::getIntegerValue(
llvm::IntegerType::get(Instr->getContext(), 32),
llvm::APInt(32, (uint64_t)val)));
}
};

/// This instruction Creates a handle to a NodeOutput
Expand Down Expand Up @@ -8883,6 +8892,15 @@ struct DxilInst_CreateNodeOutputHandle {
// Accessors
llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); }
void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); }
int32_t get_MetadataIdx_val() const {
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))
->getZExtValue());
}
void set_MetadataIdx_val(int32_t val) {
Instr->setOperand(1, llvm::Constant::getIntegerValue(
llvm::IntegerType::get(Instr->getContext(), 32),
llvm::APInt(32, (uint64_t)val)));
}
};

/// This instruction returns the handle for the location in the output node
Expand Down Expand Up @@ -8972,6 +8990,15 @@ struct DxilInst_CreateNodeInputRecordHandle {
// Accessors
llvm::Value *get_MetadataIdx() const { return Instr->getOperand(1); }
void set_MetadataIdx(llvm::Value *val) { Instr->setOperand(1, val); }
int32_t get_MetadataIdx_val() const {
return (int32_t)(llvm::dyn_cast<llvm::ConstantInt>(Instr->getOperand(1))
->getZExtValue());
}
void set_MetadataIdx_val(int32_t val) {
Instr->setOperand(1, llvm::Constant::getIntegerValue(
llvm::IntegerType::get(Instr->getContext(), 32),
llvm::APInt(32, (uint64_t)val)));
}
};

/// This instruction annotate handle with node record properties
Expand Down
8 changes: 5 additions & 3 deletions utils/hct/hctdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5396,7 +5396,9 @@ def UFI(name, **mappings):
[
retvoid_param,
db_dxil_param(2, "noderecordhandle", "object", "handle of object"),
db_dxil_param(3, "i32", "SemanticFlags", "semantic flags"),
db_dxil_param(
3, "i32", "SemanticFlags", "semantic flags", is_const=True
),
],
)
next_op_idx += 1
Expand All @@ -5409,7 +5411,7 @@ def UFI(name, **mappings):
"rn",
[
db_dxil_param(0, "nodehandle", "output", "handle of object"),
db_dxil_param(2, "i32", "MetadataIdx", "metadata index"),
db_dxil_param(2, "i32", "MetadataIdx", "metadata index", is_const=True),
],
)
next_op_idx += 1
Expand Down Expand Up @@ -5461,7 +5463,7 @@ def UFI(name, **mappings):
"rn",
[
db_dxil_param(0, "noderecordhandle", "output", "output handle"),
db_dxil_param(2, "i32", "MetadataIdx", "metadata index"),
db_dxil_param(2, "i32", "MetadataIdx", "metadata index", is_const=True),
],
)
next_op_idx += 1
Expand Down

0 comments on commit df588be

Please sign in to comment.