Split out parts of scompare_loc_descriptor and emit_store_flag
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_asm.h
blob737ccbb716db06b0d75e8fa3f3b25607671d2c57
1 //===-- sanitizer_asm.h -----------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Various support for assemebler.
9 //
10 //===----------------------------------------------------------------------===//
12 // Some toolchains do not support .cfi asm directives, so we have to hide
13 // them inside macros.
14 #if defined(__clang__) || \
15 (defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM))
16 // GCC defined __GCC_HAVE_DWARF2_CFI_ASM if it supports CFI.
17 // Clang seems to support CFI by default (or not?).
18 // We need two versions of macros: for inline asm and standalone asm files.
19 # define CFI_INL_ADJUST_CFA_OFFSET(n) ".cfi_adjust_cfa_offset " #n ";"
21 # define CFI_STARTPROC .cfi_startproc
22 # define CFI_ENDPROC .cfi_endproc
23 # define CFI_ADJUST_CFA_OFFSET(n) .cfi_adjust_cfa_offset n
24 # define CFI_DEF_CFA_OFFSET(n) .cfi_def_cfa_offset n
25 # define CFI_REL_OFFSET(reg, n) .cfi_rel_offset reg, n
26 # define CFI_OFFSET(reg, n) .cfi_offset reg, n
27 # define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
28 # define CFI_DEF_CFA(reg, n) .cfi_def_cfa reg, n
29 # define CFI_RESTORE(reg) .cfi_restore reg
31 #else // No CFI
32 # define CFI_INL_ADJUST_CFA_OFFSET(n)
33 # define CFI_STARTPROC
34 # define CFI_ENDPROC
35 # define CFI_ADJUST_CFA_OFFSET(n)
36 # define CFI_DEF_CFA_OFFSET(n)
37 # define CFI_REL_OFFSET(reg, n)
38 # define CFI_OFFSET(reg, n)
39 # define CFI_DEF_CFA_REGISTER(reg)
40 # define CFI_DEF_CFA(reg, n)
41 # define CFI_RESTORE(reg)
42 #endif
44 #if !defined(__APPLE__)
45 # define ASM_HIDDEN(symbol) .hidden symbol
46 # define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
47 # define ASM_SIZE(symbol) .size symbol, .-symbol
48 # define ASM_TSAN_SYMBOL(symbol) symbol
49 # define ASM_TSAN_SYMBOL_INTERCEPTOR(symbol) symbol
50 #else
51 # define ASM_HIDDEN(symbol)
52 # define ASM_TYPE_FUNCTION(symbol)
53 # define ASM_SIZE(symbol)
54 # define ASM_TSAN_SYMBOL(symbol) _##symbol
55 # define ASM_TSAN_SYMBOL_INTERCEPTOR(symbol) _wrap_##symbol
56 #endif