Semantics of the
We use the 20 bits of the immediate as
the high bits of an unsigned 21-bit integer,
whose low bit is 0 (i.e. the immediate measures multiples of 2);
the unsigned 21-bit integer is sign-extended to 64 bits,
obtaining an offset.
We add the offset to the address of the instruction,
which is passed as the
Function:
(defun exec64-jal (rd imm pc stat) (declare (xargs :guard (and (ubyte5p rd) (ubyte20p imm) (ubyte64p pc) (state64p stat)))) (let ((__function__ 'exec64-jal)) (declare (ignorable __function__)) (b* ((offset (loghead 64 (logext 21 (ash (ubyte20-fix imm) 1)))) (pc (ubyte64-fix pc)) (target-pc (+ pc offset)) (next-pc (+ pc 4)) (stat (write64-xreg rd next-pc stat)) (stat (write64-pc target-pc stat))) stat)))
Theorem:
(defthm state64p-of-exec64-jal (b* ((new-stat (exec64-jal rd imm pc stat))) (state64p new-stat)) :rule-classes :rewrite)
Theorem:
(defthm exec64-jal-of-ubyte5-fix-rd (equal (exec64-jal (ubyte5-fix rd) imm pc stat) (exec64-jal rd imm pc stat)))
Theorem:
(defthm exec64-jal-ubyte5-equiv-congruence-on-rd (implies (ubyte5-equiv rd rd-equiv) (equal (exec64-jal rd imm pc stat) (exec64-jal rd-equiv imm pc stat))) :rule-classes :congruence)
Theorem:
(defthm exec64-jal-of-ubyte20-fix-imm (equal (exec64-jal rd (ubyte20-fix imm) pc stat) (exec64-jal rd imm pc stat)))
Theorem:
(defthm exec64-jal-ubyte20-equiv-congruence-on-imm (implies (acl2::ubyte20-equiv imm imm-equiv) (equal (exec64-jal rd imm pc stat) (exec64-jal rd imm-equiv pc stat))) :rule-classes :congruence)
Theorem:
(defthm exec64-jal-of-ubyte64-fix-pc (equal (exec64-jal rd imm (ubyte64-fix pc) stat) (exec64-jal rd imm pc stat)))
Theorem:
(defthm exec64-jal-ubyte64-equiv-congruence-on-pc (implies (acl2::ubyte64-equiv pc pc-equiv) (equal (exec64-jal rd imm pc stat) (exec64-jal rd imm pc-equiv stat))) :rule-classes :congruence)
Theorem:
(defthm exec64-jal-of-state64-fix-stat (equal (exec64-jal rd imm pc (state64-fix stat)) (exec64-jal rd imm pc stat)))
Theorem:
(defthm exec64-jal-state64-equiv-congruence-on-stat (implies (state64-equiv stat stat-equiv) (equal (exec64-jal rd imm pc stat) (exec64-jal rd imm pc stat-equiv))) :rule-classes :congruence)