@@ -131,6 +131,7 @@ impl X86InlineAsmRegClass {
131131fn x86_64_only (
132132 arch : InlineAsmArch ,
133133 _has_feature : impl FnMut ( & str ) -> bool ,
134+ _allocating : bool ,
134135) -> Result < ( ) , & ' static str > {
135136 match arch {
136137 InlineAsmArch :: X86 => Err ( "register is only available on x86_64" ) ,
@@ -139,6 +140,20 @@ fn x86_64_only(
139140 }
140141}
141142
143+ fn high_byte (
144+ arch : InlineAsmArch ,
145+ _has_feature : impl FnMut ( & str ) -> bool ,
146+ allocating : bool ,
147+ ) -> Result < ( ) , & ' static str > {
148+ match arch {
149+ InlineAsmArch :: X86_64 if allocating => {
150+ // The error message isn't actually used...
151+ Err ( "high byte registers are not allocated by reg_byte" )
152+ }
153+ _ => Ok ( ( ) ) ,
154+ }
155+ }
156+
142157def_regs ! {
143158 X86 X86InlineAsmReg X86InlineAsmRegClass {
144159 ax: reg, reg_abcd = [ "ax" , "eax" , "rax" ] ,
@@ -156,13 +171,13 @@ def_regs! {
156171 r14: reg = [ "r14" , "r14w" , "r14d" ] % x86_64_only,
157172 r15: reg = [ "r15" , "r15w" , "r15d" ] % x86_64_only,
158173 al: reg_byte = [ "al" ] ,
159- ah: reg_byte = [ "ah" ] ,
174+ ah: reg_byte = [ "ah" ] % high_byte ,
160175 bl: reg_byte = [ "bl" ] ,
161- bh: reg_byte = [ "bh" ] ,
176+ bh: reg_byte = [ "bh" ] % high_byte ,
162177 cl: reg_byte = [ "cl" ] ,
163- ch: reg_byte = [ "ch" ] ,
178+ ch: reg_byte = [ "ch" ] % high_byte ,
164179 dl: reg_byte = [ "dl" ] ,
165- dh: reg_byte = [ "dh" ] ,
180+ dh: reg_byte = [ "dh" ] % high_byte ,
166181 sil: reg_byte = [ "sil" ] % x86_64_only,
167182 dil: reg_byte = [ "dil" ] % x86_64_only,
168183 r8b: reg_byte = [ "r8b" ] % x86_64_only,
0 commit comments