Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv64: Remove support for fixed offset jumps from Jump instructions #6988

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions cranelift/codegen/src/isa/riscv64/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@

(Jal
;; (rd WritableReg) don't use
(dest BranchTarget))
(label MachLabel))

(CondBr
(taken BranchTarget)
(not_taken BranchTarget)
(taken CondBrTarget)
(not_taken CondBrTarget)
(kind IntegerCompare))

;; Load an inline symbol reference.
Expand Down Expand Up @@ -231,7 +231,7 @@
(index Reg)
(tmp1 WritableReg)
(tmp2 WritableReg)
(targets VecBranchTarget))
(targets VecMachLabel))

;; atomic compare and set operation
(AtomicCas
Expand Down Expand Up @@ -767,7 +767,6 @@
;;;; lowest four bit are used.
(type FenceReq (primitive u8))

(type VecBranchTarget (primitive VecBranchTarget))
(type BoxCallInfo (primitive BoxCallInfo))
(type BoxCallIndInfo (primitive BoxCallIndInfo))
(type BoxReturnCallInfo (primitive BoxReturnCallInfo))
Expand All @@ -781,7 +780,7 @@
(type Imm5 (primitive Imm5))
(type Imm20 (primitive Imm20))
(type Imm3 (primitive Imm3))
(type BranchTarget (primitive BranchTarget))
(type CondBrTarget (primitive CondBrTarget))
(type OptionFloatRoundingMode (primitive OptionFloatRoundingMode))
(type VecU8 (primitive VecU8))
(type AMO (primitive AMO))
Expand Down Expand Up @@ -2664,21 +2663,6 @@
(test XReg (rv_srli sum (imm12_const (ty_bits ty)))))
(value_regs sum test)))

(decl label_to_br_target (MachLabel) BranchTarget)
(extern constructor label_to_br_target label_to_br_target)

(decl gen_jump (MachLabel) MInst)
(rule
(gen_jump v)
(MInst.Jal (label_to_br_target v)))

(decl vec_label_get (VecMachLabel u8) MachLabel )
(extern constructor vec_label_get vec_label_get)

(decl partial lower_branch (Inst VecMachLabel) Unit)
(rule (lower_branch (jump _) targets )
(emit_side_effect (SideEffectNoResult.Inst (gen_jump (vec_label_get targets 0)))))

;;; cc a b targets Type
(decl lower_br_icmp (IntCC ValueRegs ValueRegs VecMachLabel Type) Unit)
(extern constructor lower_br_icmp lower_br_icmp)
Expand Down Expand Up @@ -2722,6 +2706,17 @@
(hi XReg (value_regs_get regs 1)))
(rv_or lo hi)))


(decl label_to_br_target (MachLabel) CondBrTarget)
(extern constructor label_to_br_target label_to_br_target)

(decl vec_label_get (VecMachLabel u8) MachLabel)
(extern constructor vec_label_get vec_label_get)

(decl partial lower_branch (Inst VecMachLabel) Unit)
(rule (lower_branch (jump _) targets )
(emit_side_effect (SideEffectNoResult.Inst (MInst.Jal (vec_label_get targets 0)))))

;; Default behavior for branching based on an input value.
(rule
(lower_branch (brif v @ (value_type ty) _ _) targets)
Expand All @@ -2743,23 +2738,22 @@
(rule 1
(lower_branch (brif (maybe_uextend (fcmp cc a @ (value_type ty) b)) _ _) targets)
(if-let $true (floatcc_unordered cc))
(let ((then BranchTarget (label_to_br_target (vec_label_get targets 0)))
(else BranchTarget (label_to_br_target (vec_label_get targets 1))))
(let ((then CondBrTarget (label_to_br_target (vec_label_get targets 0)))
(else CondBrTarget (label_to_br_target (vec_label_get targets 1))))
(emit_side_effect (cond_br (emit_fcmp (floatcc_complement cc) ty a b) else then))))

(rule 1
(lower_branch (brif (maybe_uextend (fcmp cc a @ (value_type ty) b)) _ _) targets)
(if-let $false (floatcc_unordered cc))
(let ((then BranchTarget (label_to_br_target (vec_label_get targets 0)))
(else BranchTarget (label_to_br_target (vec_label_get targets 1))))
(let ((then CondBrTarget (label_to_br_target (vec_label_get targets 0)))
(else CondBrTarget (label_to_br_target (vec_label_get targets 1))))
(emit_side_effect (cond_br (emit_fcmp cc ty a b) then else))))

;;;

(decl lower_br_table (Reg VecMachLabel) Unit)
(extern constructor lower_br_table lower_br_table)

(rule
(lower_branch (br_table index _) targets)
(rule (lower_branch (br_table index _) targets)
(lower_br_table index targets))

(decl load_ra () Reg)
Expand Down Expand Up @@ -2987,7 +2981,7 @@
(rule (cmp_result_invert result) (CmpResult.Result result $true))

;; Consume a CmpResult, producing a branch on its result.
(decl cond_br (CmpResult BranchTarget BranchTarget) SideEffectNoResult)
(decl cond_br (CmpResult CondBrTarget CondBrTarget) SideEffectNoResult)
(rule (cond_br cmp then else)
(SideEffectNoResult.Inst
(MInst.CondBr then else (cmp_integer_compare cmp))))
Expand Down
Loading