1; RUN: llvm-mc -triple avr -show-encoding < %s | FileCheck %s 2 3; TODO: Add support for lo8(-foo + 3), and add test 4; FIXME: most of these tests use values (i.e. 0x0815) that are out of bounds. 5 6foo: 7 8 ldi r24, lo8(0x42) 9 ldi r24, lo8(0x2342) 10 11 ldi r24, lo8(0x23) 12 ldi r24, hi8(0x2342) 13 14; CHECK: ldi r24, lo8(66) ; encoding: [0x82,0xe4] 15; CHECK: ldi r24, lo8(9026) ; encoding: [0x82,0xe4] 16 17; CHECK: ldi r24, lo8(35) ; encoding: [0x83,0xe2] 18; CHECK: ldi r24, hi8(9026) ; encoding: [0x83,0xe2] 19 20 21bar: 22 23 ldi r24, lo8(bar) 24 ldi r24, hi8(bar) 25 26; CHECK: ldi r24, lo8(bar) ; encoding: [0x80'A',0xe0] 27; CHECK: ; fixup A - offset: 0, value: lo8(bar), kind: fixup_lo8_ldi 28; CHECK: ldi r24, hi8(bar) ; encoding: [0x80'A',0xe0] 29; CHECK: ; fixup A - offset: 0, value: hi8(bar), kind: fixup_hi8_ldi 30 31lo8: 32 33 ldi r24, lo8(0x0815) 34 ldi r24, lo8(foo) 35 ldi r24, lo8(bar + 5) 36 37; CHECK: ldi r24, lo8(2069) ; encoding: [0x85,0xe1] 38; CHECK: ldi r24, lo8(foo) ; encoding: [0x80'A',0xe0] 39; CHECK: ; fixup A - offset: 0, value: lo8(foo), kind: fixup_lo8_ldi 40; CHECK: ldi r24, lo8(bar+5) ; encoding: [0x80'A',0xe0] 41; CHECK: ; fixup A - offset: 0, value: lo8(bar+5), kind: fixup_lo8_ldi 42 43lo8_neg: 44 45 ldi r24, -lo8(123456) 46 ldi r24, -lo8(foo) 47 48; CHECK: ldi r24, -lo8(123456) ; encoding: [0x80,0xec] 49; CHECK: ldi r24, -lo8(foo) ; encoding: [0x80'A',0xe0] 50; CHECK: ; fixup A - offset: 0, value: -lo8(foo), kind: fixup_lo8_ldi_neg 51 52hi8: 53 54 ldi r24, hi8(0x0815) 55 ldi r24, hi8(foo) 56 ldi r24, hi8(bar + 5) 57 58; CHECK: ldi r24, hi8(2069) ; encoding: [0x88,0xe0] 59; CHECK: ldi r24, hi8(foo) ; encoding: [0x80'A',0xe0] 60; CHECK: ; fixup A - offset: 0, value: hi8(foo), kind: fixup_hi8_ldi 61; CHECK: ldi r24, hi8(bar+5) ; encoding: [0x80'A',0xe0] 62; CHECK: ; fixup A - offset: 0, value: hi8(bar+5), kind: fixup_hi8_ldi 63 64hi8_neg: 65 66 ldi r24, -hi8(123456) 67 ldi r24, -hi8(foo) 68 69; CHECK: ldi r24, -hi8(123456) ; encoding: [0x8d,0xe1] 70; CHECK: ldi r24, -hi8(foo) ; encoding: [0x80'A',0xe0] 71; CHECK: ; fixup A - offset: 0, value: -hi8(foo), kind: fixup_hi8_ldi_neg 72 73hh8: 74 75 ldi r24, hh8(0x0815) 76 ldi r24, hh8(foo) 77 ldi r24, hh8(bar + 5) 78 79; CHECK: ldi r24, hh8(2069) ; encoding: [0x80,0xe0] 80; CHECK: ldi r24, hh8(foo) ; encoding: [0x80'A',0xe0] 81; CHECK: ; fixup A - offset: 0, value: hh8(foo), kind: fixup_hh8_ldi 82; CHECK: ldi r24, hh8(bar+5) ; encoding: [0x80'A',0xe0] 83; CHECK: ; fixup A - offset: 0, value: hh8(bar+5), kind: fixup_hh8_ldi 84 85hh8_neg: 86 87 ldi r24, -hh8(123456) 88 ldi r24, -hh8(foo) 89 90; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef] 91; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0] 92; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg 93 94hlo8: ; synonym with hh8() above, hence the... odd results 95 96 ldi r24, hlo8(0x0815) 97 ldi r24, hlo8(foo) 98 ldi r24, hlo8(bar + 5) 99 100; CHECK: ldi r24, hh8(2069) ; encoding: [0x80,0xe0] 101; CHECK: ldi r24, hh8(foo) ; encoding: [0x80'A',0xe0] 102; CHECK: ; fixup A - offset: 0, value: hh8(foo), kind: fixup_hh8_ldi 103; CHECK: ldi r24, hh8(bar+5) ; encoding: [0x80'A',0xe0] 104; CHECK: ; fixup A - offset: 0, value: hh8(bar+5), kind: fixup_hh8_ldi 105 106hlo8_neg: 107 108 ldi r24, -hlo8(123456) 109 ldi r24, -hlo8(foo) 110 111 112; CHECK: ldi r24, -hh8(123456) ; encoding: [0x8e,0xef] 113; CHECK: ldi r24, -hh8(foo) ; encoding: [0x80'A',0xe0] 114; CHECK: ; fixup A - offset: 0, value: -hh8(foo), kind: fixup_hh8_ldi_neg 115 116hhi8: 117 118 ldi r24, hhi8(0x0815) 119 ldi r24, hhi8(foo) 120 ldi r24, hhi8(bar + 5) 121 122; CHECK: ldi r24, hhi8(2069) ; encoding: [0x80,0xe0] 123; CHECK: ldi r24, hhi8(foo) ; encoding: [0x80'A',0xe0] 124; CHECK: ; fixup A - offset: 0, value: hhi8(foo), kind: fixup_ms8_ldi 125; CHECK: ldi r24, hhi8(bar+5) ; encoding: [0x80'A',0xe0] 126; CHECK: ; fixup A - offset: 0, value: hhi8(bar+5), kind: fixup_ms8_ldi 127 128hhi8_neg: 129 ldi r24, -hhi8(123456) 130 ldi r24, -hhi8(foo) 131 132 133; CHECK: ldi r24, -hhi8(123456) ; encoding: [0x8f,0xef] 134; CHECK: ldi r24, -hhi8(foo) ; encoding: [0x80'A',0xe0] 135; CHECK: ; fixup A - offset: 0, value: -hhi8(foo), kind: fixup_ms8_ldi_neg 136 137pm_lo8: 138 ldi r24, pm_lo8(0x0815) 139 ldi r24, pm_lo8(foo) 140 ldi r24, pm_lo8(bar + 5) 141 142; CHECK: ldi r24, pm_lo8(2069) ; encoding: [0x8a,0xe0] 143; CHECK: ldi r24, pm_lo8(foo) ; encoding: [0x80'A',0xe0] 144; CHECK: ; fixup A - offset: 0, value: pm_lo8(foo), kind: fixup_lo8_ldi_pm 145; CHECK: ldi r24, pm_lo8(bar+5) ; encoding: [0x80'A',0xe0] 146; CHECK: ; fixup A - offset: 0, value: pm_lo8(bar+5), kind: fixup_lo8_ldi_pm 147 148pm_hi8: 149 ldi r24, pm_hi8(0x0815) 150 ldi r24, pm_hi8(foo) 151 ldi r24, pm_hi8(bar + 5) 152 153; CHECK: ldi r24, pm_hi8(2069) ; encoding: [0x84,0xe0] 154; CHECK: ldi r24, pm_hi8(foo) ; encoding: [0x80'A',0xe0] 155; CHECK: ; fixup A - offset: 0, value: pm_hi8(foo), kind: fixup_hi8_ldi_pm 156; CHECK: ldi r24, pm_hi8(bar+5) ; encoding: [0x80'A',0xe0] 157; CHECK: ; fixup A - offset: 0, value: pm_hi8(bar+5), kind: fixup_hi8_ldi_pm 158 159pm_hh8: 160 ldi r24, pm_hh8(0x0815) 161 ldi r24, pm_hh8(foo) 162 ldi r24, pm_hh8(bar + 5) 163 164; CHECK: ldi r24, pm_hh8(2069) ; encoding: [0x80,0xe0] 165; CHECK: ldi r24, pm_hh8(foo) ; encoding: [0x80'A',0xe0] 166; CHECK: ; fixup A - offset: 0, value: pm_hh8(foo), kind: fixup_hh8_ldi_pm 167; CHECK: ldi r24, pm_hh8(bar+5) ; encoding: [0x80'A',0xe0] 168; CHECK: ; fixup A - offset: 0, value: pm_hh8(bar+5), kind: fixup_hh8_ldi_pm 169 170 171pm_lo8_neg: 172 ldi r24, -pm_lo8(0x0815) 173 ldi r24, -pm_lo8(foo) 174 ldi r24, -pm_lo8(bar + 5) 175 176; CHECK: ldi r24, -pm_lo8(2069) ; encoding: [0x85,0xef] 177; CHECK: ldi r24, -pm_lo8(foo) ; encoding: [0x80'A',0xe0] 178; CHECK: ; fixup A - offset: 0, value: -pm_lo8(foo), kind: fixup_lo8_ldi_pm_neg 179; CHECK: ldi r24, -pm_lo8(bar+5) ; encoding: [0x80'A',0xe0] 180; CHECK: ; fixup A - offset: 0, value: -pm_lo8(bar+5), kind: fixup_lo8_ldi_pm_neg 181 182pm_hi8_neg: 183 ldi r24, -pm_hi8(0x0815) 184 ldi r24, -pm_hi8(foo) 185 ldi r24, -pm_hi8(bar + 5) 186 187; CHECK: ldi r24, -pm_hi8(2069) ; encoding: [0x8b,0xef] 188; CHECK: ldi r24, -pm_hi8(foo) ; encoding: [0x80'A',0xe0] 189; CHECK: ; fixup A - offset: 0, value: -pm_hi8(foo), kind: fixup_hi8_ldi_pm_neg 190; CHECK: ldi r24, -pm_hi8(bar+5) ; encoding: [0x80'A',0xe0] 191; CHECK: ; fixup A - offset: 0, value: -pm_hi8(bar+5), kind: fixup_hi8_ldi_pm_neg 192 193pm_hh8_neg: 194 ldi r24, -pm_hh8(0x0815) 195 ldi r24, -pm_hh8(foo) 196 ldi r24, -pm_hh8(bar + 5) 197 198; CHECK: ldi r24, -pm_hh8(2069) ; encoding: [0x8f,0xef] 199; CHECK: ldi r24, -pm_hh8(foo) ; encoding: [0x80'A',0xe0] 200; CHECK: ; fixup A - offset: 0, value: -pm_hh8(foo), kind: fixup_hh8_ldi_pm_neg 201; CHECK: ldi r24, -pm_hh8(bar+5) ; encoding: [0x80'A',0xe0] 202; CHECK: ; fixup A - offset: 0, value: -pm_hh8(bar+5), kind: fixup_hh8_ldi_pm_neg 203 204