|
942 | 942 | (cond Cond) |
943 | 943 | (trap_code TrapCode)) |
944 | 944 |
|
945 | | - ;; A one-way conditional branch, invisible to the CFG processing; used *only* as part of |
946 | | - ;; straight-line sequences in code to be emitted. |
947 | | - ;; |
948 | | - ;; In more detail: |
949 | | - ;; - This branch is lowered to a branch at the machine-code level, but does not end a basic |
950 | | - ;; block, and does not create edges in the CFG seen by regalloc. |
951 | | - ;; - Thus, it is *only* valid to use as part of a single-in, single-out sequence that is |
952 | | - ;; lowered from a single CLIF instruction. For example, certain arithmetic operations may |
953 | | - ;; use these branches to handle certain conditions, such as overflows, traps, etc. |
954 | | - ;; |
955 | | - ;; See, e.g., the lowering of `trapif` (conditional trap) for an example. |
956 | | - (OneWayCondBr |
957 | | - (target MachLabel) |
958 | | - (cond Cond)) |
959 | | - |
960 | 945 | ;; An indirect branch through a register, augmented with set of all |
961 | 946 | ;; possible successors. |
962 | 947 | (IndirectBr |
|
974 | 959 | ;; Jump-table sequence, as one compound instruction (see note in lower.rs |
975 | 960 | ;; for rationale). |
976 | 961 | (JTSequence |
| 962 | + ;; The index into the list of targets. |
977 | 963 | (ridx Reg) |
| 964 | + ;; The default target. |
| 965 | + (default MachLabel) |
| 966 | + ;; The condition for taking the default target, based on flags |
| 967 | + ;; when this instruction executes. |
| 968 | + (default_cond Cond) |
| 969 | + ;; All other targets. |
978 | 970 | (targets BoxVecMachLabel)) |
979 | 971 |
|
980 | 972 | ;; Stack probe loop sequence, as one compound instruction. |
|
2702 | 2694 | (rule (cond_br taken not_taken cond) |
2703 | 2695 | (ConsumesFlags.ConsumesFlagsSideEffect (MInst.CondBr taken not_taken cond))) |
2704 | 2696 |
|
2705 | | -;; Helper for emitting `MInst.OneWayCondBr` instructions. |
2706 | | -(decl oneway_cond_br (MachLabel Cond) ConsumesFlags) |
2707 | | -(rule (oneway_cond_br dest cond) |
2708 | | - (ConsumesFlags.ConsumesFlagsSideEffect (MInst.OneWayCondBr dest cond))) |
2709 | | - |
2710 | 2697 | ;; Helper for emitting `MInst.JTSequence` instructions. |
2711 | | -(decl jt_sequence (Reg BoxVecMachLabel) SideEffectNoResult) |
2712 | | -(rule (jt_sequence ridx targets) |
2713 | | - (SideEffectNoResult.Inst (MInst.JTSequence ridx targets))) |
2714 | | - |
| 2698 | +(decl jt_sequence (Reg MachLabel Cond BoxVecMachLabel) ConsumesFlags) |
| 2699 | +(rule (jt_sequence ridx default default_cond targets) |
| 2700 | + (ConsumesFlags.ConsumesFlagsSideEffect (MInst.JTSequence ridx default default_cond targets))) |
2715 | 2701 |
|
2716 | 2702 | ;; Helpers for instruction sequences ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2717 | 2703 |
|
|
3324 | 3310 | (decl bool (ProducesFlags Cond) ProducesBool) |
3325 | 3311 | (rule (bool producer cond) (ProducesBool.ProducesBool producer cond)) |
3326 | 3312 |
|
| 3313 | +;; Get the producer from a ProducesBool. |
| 3314 | +(decl bool_producer (ProducesBool) ProducesFlags) |
| 3315 | +(rule (bool_producer (ProducesBool.ProducesBool producer _)) producer) |
| 3316 | + |
| 3317 | +;; Get the condition from a ProducesBool. |
| 3318 | +(decl bool_cond (ProducesBool) Cond) |
| 3319 | +(rule (bool_cond (ProducesBool.ProducesBool _ cond)) cond) |
| 3320 | + |
3327 | 3321 | ;; Invert boolean condition. |
3328 | 3322 | (decl invert_bool (ProducesBool) ProducesBool) |
3329 | 3323 | (rule (invert_bool (ProducesBool.ProducesBool producer cond)) |
|
3358 | 3352 | (rule (cond_br_bool (ProducesBool.ProducesBool producer cond) taken not_taken) |
3359 | 3353 | (with_flags_side_effect producer (cond_br taken not_taken cond))) |
3360 | 3354 |
|
3361 | | -;; Emit a one-way conditional branch based on a boolean condition. |
3362 | | -(decl oneway_cond_br_bool (ProducesBool MachLabel) SideEffectNoResult) |
3363 | | -(rule (oneway_cond_br_bool (ProducesBool.ProducesBool producer cond) dest) |
3364 | | - (with_flags_side_effect producer (oneway_cond_br dest cond))) |
3365 | | - |
3366 | 3355 | ;; Emit a conditional trap based on a boolean condition. |
3367 | 3356 | (decl trap_if_bool (ProducesBool TrapCode) SideEffectNoResult) |
3368 | 3357 | (rule (trap_if_bool (ProducesBool.ProducesBool producer cond) trap_code) |
|
0 commit comments