Last active
March 1, 2023 10:30
-
-
Save lundman/582020898f611c28fd0d1a55e46e0a03 to your computer and use it in GitHub Desktop.
Testing macros in clang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.macro bytereg reg | |
.if \reg == %r8 || \reg == %r9 || \reg == %r10 || \reg == %r11 || \reg == %r12 || \reg == %r13 || \reg == %r14 || \reg == %r15 | |
.set breg, \reg\()b | |
.elseif \reg == %rax | |
.set breg, %al | |
.elseif \reg == %rcx | |
.set breg, %cl | |
.elseif \reg == %rdx | |
.set breg, %dl | |
.elseif \reg == %rbx | |
.set breg, %bl | |
.elseif \reg == rsp | |
.set breg, %spl | |
.elseif \reg == %rbp | |
.set breg, %bpl | |
.elseif \reg == rsi | |
.set breg, %sil | |
.elseif \reg == rdi | |
.set breg, %dil | |
.else | |
.error "Invalid register '\reg\()' while expanding macro 'bytereg\()'" | |
.endif | |
.endm | |
.macro READ_SMALL_DATA_INPUT TMP | |
bytereg \TMP | |
movb 0, breg | |
.endm | |
test: | |
READ_SMALL_DATA_INPUT %r11 | |
// macOS: | |
// large - how its assembled in the project | |
// gcc -DHAVE_CONFIG_H -I. -Wall -nostdinc -mkernel -fno-builtin-printf -Wframe-larger-than=400 -D__KERNEL__ -D_KERNEL | |
// -DKERNEL -DKERNEL_PRIVATE -DDRIVER_PRIVATE -UHAVE_LARGE_STACKS -DNAMEDSTREAMS=1 -D__DARWIN_64_BIT_INO_T=1 -DAPPLE | |
// -DNeXT -include ./zfs_config.h -I./include/os/macos/spl -I./include/os/macos/zfs -I./module/icp/include -I./include | |
// -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Kernel.framework/Headers | |
// -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Kernel.framework/PrivateHeaders | |
// -I./module/zstd/include -UDEBUG -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/[email protected]/include | |
// -O2 -g -MT module/os/macos/../../icp/asm-x86_64/modes/macos_zfs-isalc_gcm128_sse.o -MD -MP -MF | |
// module/os/macos/../../icp/asm-x86_64/modes/.deps/macos_zfs-isalc_gcm128_sse.Tpo -c -o | |
// module/os/macos/../../icp/asm-x86_64/modes/macos_zfs-test.o `test -f 'module/os/macos/../../icp/asm-x86_64/modes/test.S' || | |
// echo './'`module/os/macos/../../icp/asm-x86_64/modes/test.S | |
// | |
// llvm-objdump --disassemble macos_zfs-test.o | |
./module/icp/asm-x86_64/modes/macos_zfs-test.o: file format Mach-O 64-bit x86-64 | |
Disassembly of section __TEXT,__text: | |
0000000000000000 test: | |
0: 44 8a 1c 25 00 00 00 00 movb 0, %r11b | |
// Windows: | |
// | |
// clang-cl.exe -DAMD64 -DDBG -DDBG=1 -DDEPRECATE_DDK_FUNCTIONS=1 -DMSC_NOOPT -DWIN64 -DWINNT=1 -DZFS_DEBUG -D_AMD64_ | |
// -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_KERNEL -D_LP64 -D_WIN32_WINNT=0x0601 -D_WIN64 -D__KERNEL__ | |
// -D__LP64__ -D__x86_64 -D__x86_64__ -I..\..\..\module\icp\include -I..\..\..\include\os\windows | |
// -I..\..\..\include\os\windows\spl -I..\..\..\include\os\windows\zfs -I..\..\..\include | |
// -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared" | |
// -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\km" | |
// -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\km\crt" /we4013 /wd4057 /wd4100 /wd4152 /wd4200 | |
// /wd4201 /wd4211 /wd4204 /wd4210 /wd4389 /wd4706 /wd4131 /wd4115 /wd4018 /wd4206 /wd4324 /wd4053 | |
// /FI C:/src/openzfs/include/os/windows/zfs/zfs_config.h -m64 -Wno-nonportable-include-path -Wno-unknown-pragmas | |
// -Wno-ignored-pragma-intrinsic -Wno-pragma-pack -Wno-microsoft-enum-forward-reference -Wno-visibility | |
// -Wno-microsoft-anon-tag -Wno-unused-command-line-argument -Wno-unused-local-typedef -Wno-int-to-void-pointer-cast | |
// -Wno-misleading-indentation -Wno-dangling-else -Wno-missing-field-initializers -Wno-unused-function -Wno-unused-label | |
// -Wno-int-conversion /X /Zp8 /GF /GR- /Gz /kernel /FIwarning.h /FIC:/src/openzfs/out/build/x64-Debug/CMakeFiles/wdkflags.h | |
// /MTd -o module\icp\CMakeFiles\icpkern.dir\asm-x86_64\modes\test.S.obj -c ..\..\..\module\icp\asm-x86_64\modes\test.S | |
<unknown>:0: error: expression could not be evaluated | |
clang -cc1as: fatal error: error in backend: unable to evaluate offset for variable 'breg' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment