65816-llvm-mos/src/llvm/test/CodeGen/W65816/i8-imm-wide.ll
2026-10-06 17:01:51 -05:00

33 lines
999 B
LLVM

; Pin: an i8 constant loaded into A is a 16-bit `lda #imm` (3 cycles),
; not `sep #0x20 ; lda #imm ; rep #0x20` (9): the byte's high half is
; nobody's business, and LDAi8imm is in the flag-wrap pass's isLdaLike
; list either way. A store's own SEP that follows still takes the 8-bit
; form and drops the REP/SEP pair between them.
;
; RUN: llc -mtriple=w65816 -O2 < %s | FileCheck %s
; RUN: env W65816_DISABLE_I8_IMM16=1 llc -mtriple=w65816 -O2 < %s | FileCheck %s --check-prefix=OFF
target datalayout = "e-m:e-p:32:16-i16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
declare i8 @takeByte(i8)
define i8 @retByte() {
; CHECK-LABEL: retByte:
; CHECK: rep #0x30
; CHECK-NEXT: lda #0x7
; CHECK-NEXT: rtl
; OFF-LABEL: retByte:
; OFF: sep #0x20
; OFF-NEXT: lda #0x7
; OFF-NEXT: rep #0x20
ret i8 7
}
define i8 @passByte() {
; CHECK-LABEL: passByte:
; CHECK: rep #0x30
; CHECK-NEXT: lda #0xfb
; CHECK-NEXT: jsl takeByte
%r = call i8 @takeByte(i8 -5)
ret i8 %r
}