Skip to content

Commit

Permalink
Merge branch 'master' into bitzoic-b256-bytez-conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzoic authored Feb 25, 2025
2 parents 31a6df6 + a090937 commit c77402b
Show file tree
Hide file tree
Showing 25 changed files with 421 additions and 33 deletions.
1 change: 1 addition & 0 deletions sway-ast/src/expr/op_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ define_op_codes!(
(ECOP, ECOPOpcode, "ecop", (dst_addr: reg, curve: reg, operation: reg, src_addr: reg)),
(EPAR, EPAROpcode, "epar", (ret: reg, curve: reg, groups_of_points: reg, addr: reg)),
/* Other Instructions */
(Ecal, EcalOpcode, "ecal", (reg_a: reg, reg_b: reg, reg_c: reg, reg_d: reg)),
(Flag, FlagOpcode, "flag", (value: reg)),
(Gm, GmOpcode, "gm", (ret: reg, op: imm)),
(
Expand Down
11 changes: 11 additions & 0 deletions sway-core/src/asm_lang/allocated_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ pub(crate) enum AllocatedOpcode {
),

/* Other Instructions */
ECAL(
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
AllocatedRegister,
),
FLAG(AllocatedRegister),
GM(AllocatedRegister, VirtualImmediate18),
GTF(AllocatedRegister, AllocatedRegister, VirtualImmediate12),
Expand Down Expand Up @@ -408,6 +414,7 @@ impl AllocatedOpcode {
EPAR(r1, _r2, _r3, _r4) => vec![r1],

/* Other Instructions */
ECAL(_r1, _r2, _r3, _r4) => vec![],
FLAG(_r1) => vec![],
GM(r1, _imm) => vec![r1],
GTF(r1, _r2, _i) => vec![r1],
Expand Down Expand Up @@ -539,6 +546,7 @@ impl fmt::Display for AllocatedOpcode {
EPAR(a, b, c, d) => write!(fmtr, "epar {a} {b} {c} {d}"),

/* Other Instructions */
ECAL(a, b, c, d) => write!(fmtr, "ecal {a} {b} {c} {d}"),
FLAG(a) => write!(fmtr, "flag {a}"),
GM(a, b) => write!(fmtr, "gm {a} {b}"),
GTF(a, b, c) => write!(fmtr, "gtf {a} {b} {c}"),
Expand Down Expand Up @@ -775,6 +783,9 @@ impl AllocatedOp {
}

/* Other Instructions */
ECAL(a, b, c, d) => {
op::ECAL::new(a.to_reg_id(), b.to_reg_id(), c.to_reg_id(), d.to_reg_id()).into()
}
FLAG(a) => op::FLAG::new(a.to_reg_id()).into(),
GM(a, b) => op::GM::new(a.to_reg_id(), b.value().into()).into(),
GTF(a, b, c) => op::GTF::new(a.to_reg_id(), b.to_reg_id(), c.value().into()).into(),
Expand Down
9 changes: 9 additions & 0 deletions sway-core/src/asm_lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ impl Op {
let (r1, r2, r3, i0) = three_regs_imm_06(handler, args, immediate, whole_op_span)?;
VirtualOp::LDC(r1, r2, r3, i0)
}
"bldd" => {
let (r1, r2, r3, r4) = four_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::BLDD(r1, r2, r3, r4)
}
"log" => {
let (r1, r2, r3, r4) = four_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::LOG(r1, r2, r3, r4)
Expand Down Expand Up @@ -684,6 +688,10 @@ impl Op {
}

/* Other Instructions */
"ecal" => {
let (r1, r2, r3, r4) = four_regs(handler, args, immediate, whole_op_span)?;
VirtualOp::ECAL(r1, r2, r3, r4)
}
"flag" => {
let r1 = single_reg(handler, args, immediate, whole_op_span)?;
VirtualOp::FLAG(r1)
Expand Down Expand Up @@ -1240,6 +1248,7 @@ impl fmt::Display for VirtualOp {
EPAR(a, b, c, d) => write!(fmtr, "epar {a} {b} {c} {d}"),

/* Other Instructions */
ECAL(a, b, c, d) => write!(fmtr, "ecal {a} {b} {c} {d}"),
FLAG(a) => write!(fmtr, "flag {a}"),
GM(a, b) => write!(fmtr, "gm {a} {b}"),
GTF(a, b, c) => write!(fmtr, "gtf {a} {b} {c}"),
Expand Down
24 changes: 24 additions & 0 deletions sway-core/src/asm_lang/virtual_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ pub(crate) enum VirtualOp {
),

/* Other Instructions */
ECAL(
VirtualRegister,
VirtualRegister,
VirtualRegister,
VirtualRegister,
),
FLAG(VirtualRegister),
GM(VirtualRegister, VirtualImmediate18),
GTF(VirtualRegister, VirtualRegister, VirtualImmediate12),
Expand Down Expand Up @@ -355,6 +361,7 @@ impl VirtualOp {
EPAR(r1, r2, r3, r4) => vec![r1, r2, r3, r4],

/* Other Instructions */
ECAL(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
FLAG(r1) => vec![r1],
GM(r1, _imm) => vec![r1],
GTF(r1, r2, _i) => vec![r1, r2],
Expand Down Expand Up @@ -479,6 +486,8 @@ impl VirtualOp {
| K256(_, _, _)
| S256(_, _, _)
| ECOP(_, _, _, _)
// Other instructions
| ECAL(_, _, _, _)
| FLAG(_)
// Virtual OPs
| BLOB(_)
Expand Down Expand Up @@ -588,6 +597,7 @@ impl VirtualOp {
| S256(_, _, _)
| ECOP(_, _, _, _)
| EPAR(_, _, _, _)
| ECAL(_, _, _, _)
| GM(_, _)
| GTF(_, _, _)
| BLOB(_)
Expand Down Expand Up @@ -709,6 +719,7 @@ impl VirtualOp {
EPAR(_r1, r2, r3, r4) => vec![r2, r3, r4],

/* Other Instructions */
ECAL(r1, r2, r3, r4) => vec![r1, r2, r3, r4],
FLAG(r1) => vec![r1],
GM(_r1, _imm) => vec![],
GTF(_r1, r2, _i) => vec![r2],
Expand Down Expand Up @@ -833,6 +844,7 @@ impl VirtualOp {
EPAR(r1, _r2, _r3, _r4) => vec![r1],

/* Other Instructions */
ECAL(_r1, _r2, _r3, _r4) => vec![],
FLAG(_r1) => vec![],
GM(r1, _imm) => vec![r1],
GTF(r1, _r2, _i) => vec![r1],
Expand Down Expand Up @@ -1292,6 +1304,12 @@ impl VirtualOp {
),

/* Other Instructions */
ECAL(r1, r2, r3, r4) => Self::ECAL(
update_reg(reg_to_reg_map, r1),
update_reg(reg_to_reg_map, r2),
update_reg(reg_to_reg_map, r3),
update_reg(reg_to_reg_map, r4),
),
FLAG(r1) => Self::FLAG(update_reg(reg_to_reg_map, r1)),
GM(r1, i) => Self::GM(update_reg(reg_to_reg_map, r1), i.clone()),
GTF(r1, r2, i) => Self::GTF(
Expand Down Expand Up @@ -1785,6 +1803,12 @@ impl VirtualOp {
),

/* Other Instructions */
ECAL(reg1, reg2, reg3, reg4) => AllocatedOpcode::ECAL(
map_reg(&mapping, reg1),
map_reg(&mapping, reg2),
map_reg(&mapping, reg3),
map_reg(&mapping, reg4),
),
FLAG(reg) => AllocatedOpcode::FLAG(map_reg(&mapping, reg)),
GM(reg, imm) => AllocatedOpcode::GM(map_reg(&mapping, reg), imm.clone()),
GTF(reg1, reg2, imm) => AllocatedOpcode::GTF(
Expand Down
15 changes: 14 additions & 1 deletion sway-core/src/language/ty/code_block.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
decl_engine::*, engine_threading::*, language::ty::*, semantic_analysis::TypeCheckContext,
type_system::*,
transform::AllowDeprecatedState, type_system::*,
};
use serde::{Deserialize, Serialize};
use std::hash::Hasher;
Expand All @@ -13,6 +13,19 @@ pub struct TyCodeBlock {
pub(crate) whole_block_span: Span,
}

impl TyCodeBlock {
pub(crate) fn check_deprecated(
&self,
engines: &Engines,
handler: &Handler,
allow_deprecated: &mut AllowDeprecatedState,
) {
for n in self.contents.iter() {
n.check_deprecated(engines, handler, allow_deprecated);
}
}
}

impl Default for TyCodeBlock {
fn default() -> Self {
Self {
Expand Down
Loading

0 comments on commit c77402b

Please sign in to comment.