-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
fn reserve_freg(cfg : @ssacfg.SsaCfg) -> @ssacfg.SsaCfg { | ||
for item in cfg.blocks { | ||
let (_, block) = item | ||
let insts_backup = block.insts | ||
let insts = [] | ||
for inst in insts_backup { | ||
match inst { | ||
Prim(bind, Eq | Le as op, [lhs, rhs]) as inst => | ||
match lhs.get_type() { | ||
Double => { | ||
let lhs_is_imm = match lhs { | ||
Double(_) => true | ||
_ => false | ||
} | ||
let rhs_is_imm = match rhs { | ||
Double(_) => true | ||
_ => false | ||
} | ||
if lhs_is_imm && rhs_is_imm { | ||
let tmp = cfg.new_named("tmp", ty=Double) | ||
insts.push(@ssacfg.Inst::Copy(tmp, lhs)) | ||
insts.push(Prim(bind, op, [Var(tmp), rhs])) | ||
} else { | ||
insts.push(Prim(bind, op, [lhs, rhs])) | ||
} | ||
} | ||
_ => insts.push(inst) | ||
} | ||
inst => insts.push(inst) | ||
} | ||
} | ||
block.insts = insts | ||
} | ||
cfg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters