Properties.zig (3657B) - Raw
1 const std = @import("std"); 2 3 const Properties = @This(); 4 5 param_str: []const u8, 6 language: Language = .all_languages, 7 attributes: Attributes = Attributes{}, 8 header: Header = .none, 9 target_set: TargetSet = TargetSet.initOne(.basic), 10 11 /// Header which must be included for a builtin to be available 12 pub const Header = enum { 13 none, 14 /// stdio.h 15 stdio, 16 /// stdlib.h 17 stdlib, 18 /// setjmpex.h 19 setjmpex, 20 /// stdarg.h 21 stdarg, 22 /// string.h 23 string, 24 /// ctype.h 25 ctype, 26 /// wchar.h 27 wchar, 28 /// setjmp.h 29 setjmp, 30 /// malloc.h 31 malloc, 32 /// strings.h 33 strings, 34 /// unistd.h 35 unistd, 36 /// pthread.h 37 pthread, 38 /// math.h 39 math, 40 /// complex.h 41 complex, 42 /// Blocks.h 43 blocks, 44 }; 45 46 /// Languages in which a builtin is available 47 pub const Language = enum { 48 all_languages, 49 all_ms_languages, 50 all_gnu_languages, 51 gnu_lang, 52 }; 53 54 pub const Attributes = packed struct { 55 /// Function does not return 56 noreturn: bool = false, 57 58 /// Function has no side effects 59 pure: bool = false, 60 61 /// Function has no side effects and does not read memory 62 @"const": bool = false, 63 64 /// Signature is meaningless; use custom typecheck 65 custom_typecheck: bool = false, 66 67 /// A declaration of this builtin should be recognized even if the type doesn't match the specified signature. 68 allow_type_mismatch: bool = false, 69 70 /// this is a libc/libm function with a '__builtin_' prefix added. 71 lib_function_with_builtin_prefix: bool = false, 72 73 /// this is a libc/libm function without a '__builtin_' prefix. This builtin is disableable by '-fno-builtin-foo' 74 lib_function_without_prefix: bool = false, 75 76 /// Function returns twice (e.g. setjmp) 77 returns_twice: bool = false, 78 79 /// Nature of the format string passed to this function 80 format_kind: enum(u3) { 81 /// Does not take a format string 82 none, 83 /// this is a printf-like function whose Nth argument is the format string 84 printf, 85 /// function is like vprintf in that it accepts its arguments as a va_list rather than through an ellipsis 86 vprintf, 87 /// this is a scanf-like function whose Nth argument is the format string 88 scanf, 89 /// the function is like vscanf in that it accepts its arguments as a va_list rather than through an ellipsis 90 vscanf, 91 } = .none, 92 93 /// Position of format string argument. Only meaningful if format_kind is not .none 94 format_string_position: u5 = 0, 95 96 /// if false, arguments are not evaluated 97 eval_args: bool = true, 98 99 /// no side effects and does not read memory, but only when -fno-math-errno and FP exceptions are ignored 100 const_without_errno_and_fp_exceptions: bool = false, 101 102 /// no side effects and does not read memory, but only when FP exceptions are ignored 103 const_without_fp_exceptions: bool = false, 104 105 /// this function can be constant evaluated by the frontend 106 const_evaluable: bool = false, 107 }; 108 109 pub const Target = enum { 110 /// Supported on all targets 111 basic, 112 aarch64, 113 aarch64_neon_sve_bridge, 114 aarch64_neon_sve_bridge_cg, 115 amdgpu, 116 arm, 117 bpf, 118 hexagon, 119 hexagon_dep, 120 hexagon_map_custom_dep, 121 loong_arch, 122 mips, 123 neon, 124 nvptx, 125 ppc, 126 riscv, 127 riscv_vector, 128 sve, 129 systemz, 130 ve, 131 vevl_gen, 132 webassembly, 133 x86, 134 x86_64, 135 xcore, 136 }; 137 138 /// Targets for which a builtin is enabled 139 pub const TargetSet = std.enums.EnumSet(Target); 140 141 pub fn isVarArgs(properties: Properties) bool { 142 return properties.param_str[properties.param_str.len - 1] == '.'; 143 }