asm_constraints.h (1070B)
1 #ifndef KIT_ASM_CONSTRAINTS_H 2 #define KIT_ASM_CONSTRAINTS_H 3 4 /* Shared parsing for the target-neutral part of GCC-style inline-asm operand 5 * constraints. These helpers know only about generic modifiers and matching 6 * digits; target register letters are resolved by the selected backend. */ 7 8 static inline const char* kit_cg_asm_constraint_body(const char* s) { 9 if (!s) return ""; 10 if (s[0] == '=' && s[1] == '&') return s + 2; 11 if (s[0] == '=' || s[0] == '+' || s[0] == '&') return s + 1; 12 return s; 13 } 14 15 static inline int kit_cg_asm_constraint_early(const char* s) { 16 if (!s) return 0; 17 return (s[0] == '=' && s[1] == '&') || s[0] == '&'; 18 } 19 20 static inline int kit_cg_asm_constraint_match_index(const char* s) { 21 int n; 22 if (!s || s[0] < '0' || s[0] > '9') return -1; 23 n = 0; 24 for (; *s >= '0' && *s <= '9'; ++s) n = n * 10 + (*s - '0'); 25 return n; 26 } 27 28 static inline int kit_cg_asm_constraint_is_decimal(const char* s) { 29 if (!s || s[0] < '0' || s[0] > '9') return 0; 30 while (*s) { 31 if (*s < '0' || *s > '9') return 0; 32 ++s; 33 } 34 return 1; 35 } 36 37 #endif