Skip to content

Commit 85e3c42

Browse files
committed
const folding: rename try_get_const_int_value -> try_get_const_value
1 parent db440f0 commit 85e3c42

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum ConstValue {
4545
}
4646

4747
impl<'a, 'tcx> Builder<'a, 'tcx> {
48-
fn try_get_const_int_value(&self, val: SpirvValue) -> Option<ConstValue> {
48+
fn try_get_const_value(&self, val: SpirvValue) -> Option<ConstValue> {
4949
if let Some(const_val) = self.builder.lookup_const(val) {
5050
let x = match const_val {
5151
SpirvConst::Scalar(x) => x,
@@ -88,8 +88,8 @@ macro_rules! simple_op {
8888
assert_ty_eq!(self, lhs.ty, rhs.ty);
8989
let result_type = lhs.ty;
9090

91-
$(if let Some(const_lhs) = self.try_get_const_int_value(lhs) {
92-
if let Some(const_rhs) = self.try_get_const_int_value(rhs) {
91+
$(if let Some(const_lhs) = self.try_get_const_value(lhs) {
92+
if let Some(const_rhs) = self.try_get_const_value(rhs) {
9393
#[allow(unreachable_patterns)]
9494
match (const_lhs, const_rhs) {
9595
$(
@@ -152,8 +152,8 @@ macro_rules! simple_shift_op {
152152
fn $func_name(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value {
153153
let result_type = lhs.ty;
154154

155-
$(if let Some(const_lhs) = self.try_get_const_int_value(lhs) {
156-
if let Some(const_rhs) = self.try_get_const_int_value(rhs) {
155+
$(if let Some(const_lhs) = self.try_get_const_value(lhs) {
156+
if let Some(const_rhs) = self.try_get_const_value(rhs) {
157157
#[allow(unreachable_patterns)]
158158
match (const_lhs, const_rhs) {
159159
$(
@@ -219,7 +219,7 @@ macro_rules! simple_uni_op {
219219

220220
$(
221221
#[allow(unreachable_patterns, clippy::collapsible_match)]
222-
if let Some(const_val) = self.try_get_const_int_value(val) {
222+
if let Some(const_val) = self.try_get_const_value(val) {
223223
match const_val {
224224
$(
225225
ConstValue::Unsigned($int_val) => return self.const_uint_big(result_type, $fold_int),
@@ -2612,8 +2612,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
26122612
assert_ty_eq!(self, lhs.ty, rhs.ty);
26132613
let b = SpirvType::Bool.def(self.span(), self);
26142614

2615-
if let Some(const_lhs) = self.try_get_const_int_value(lhs) {
2616-
if let Some(const_rhs) = self.try_get_const_int_value(rhs) {
2615+
if let Some(const_lhs) = self.try_get_const_value(lhs) {
2616+
if let Some(const_rhs) = self.try_get_const_value(rhs) {
26172617
let const_result = match self.lookup_type(lhs.ty) {
26182618
SpirvType::Integer(_, _) => match (const_lhs, const_rhs, op) {
26192619
(ConstValue::Unsigned(lhs), ConstValue::Unsigned(rhs), IntEQ) => {
@@ -3072,7 +3072,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
30723072
assert_ty_eq!(self, then_val.ty, else_val.ty);
30733073
let result_type = then_val.ty;
30743074

3075-
if let Some(const_cond) = self.try_get_const_int_value(cond) {
3075+
if let Some(const_cond) = self.try_get_const_value(cond) {
30763076
if let ConstValue::Bool(b) = const_cond {
30773077
// as we directly return the values, it'll preserve their constness as well
30783078
return if b { then_val } else { else_val };

0 commit comments

Comments
 (0)