gcc 中的 unspec 与 unspec_volatile
define_insn中的RTL模板包含描述指令模式功能的表达式,这使优化程序可以推断出insn。
case 1:
Dump of assembler code for function main:
0x00000000000006aa <+0>: push rbp
0x00000000000006ab <+1>: mov rbp,rsp
0x00000000000006ae <+4>: sub rsp,0x30
0x00000000000006b2 <+8>: mov rax,QWORD PTR fs:0x28 !!!! start here
0x00000000000006bb <+17>: mov QWORD PTR [rbp-0x8],rax
0x00000000000006bf <+21>: xor eax,eax
36 (insn 3 2 32 2 (parallel [
37 (set (mem/v/f/c:DI (plus:DI (reg/f:DI 6 bp)
38 (const_int -8 [0xfffffffffffffff8])) [2 D.2256+0 S8 A64])
39 (unspec:DI [
40 (const_int 40 [0x28])
41 ] UNSPEC_SP_TLS_SET))
42 (set (reg:DI 0 ax [91])
43 (const_int 0 [0]))
44 (clobber (reg:CC 17 flags))
45 ]) "test.c":5 1012 {stack_tls_protect_set_di}
46 (nil))
这其实一种暗示,告诉编译器更多的信息,最终匹配到合适的指令s。
SSP 理解为栈保护相关的枚举变量
68 (define_c_enum "unspec" [
69 ;; Relocation specifiers
70 UNSPEC_GOT
71 UNSPEC_GOTOFF
72 UNSPEC_GOTPCREL
73 UNSPEC_GOTTPOFF
74 UNSPEC_TPOFF
75 UNSPEC_NTPOFF
76 UNSPEC_DTPOFF
77 UNSPEC_GOTNTPOFF
78 UNSPEC_INDNTPOFF
79 UNSPEC_PLTOFF
80 UNSPEC_MACHOPIC_OFFSET
81 UNSPEC_PCREL
82 UNSPEC_SIZEOF
...........
167 ;; SSP patterns
168 UNSPEC_SP_SET
169 UNSPEC_SP_TEST
170 UNSPEC_SP_TLS_SET
171 UNSPEC_SP_TLS_TEST
18786 (define_insn "stack_tls_protect_set_<mode>"
18787 [(set (match_operand:PTR 0 "memory_operand" "=m")
18788 (unspec:PTR [(match_operand:PTR 1 "const_int_operand" "i")]
18789 UNSPEC_SP_TLS_SET))
18790 (set (match_scratch:PTR 2 "=&r") (const_int 0))
18791 (clobber (reg:CC FLAGS_REG))]
18792 ""
18793 "mov{<imodesuffix>}\t{%@:%P1, %2|%2, <iptrsize> PTR %@:%P1}\;mov{<imodesuffix>}\t{%2, %0|%0, %2}\;xor{l}\t%k2, %k2"
18794 [(set_attr "type" "multi")])
未完待续。。。。。。。。。