{"id":1020,"date":"2015-07-13T18:43:50","date_gmt":"2015-07-13T09:43:50","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=1020"},"modified":"2016-06-09T18:54:19","modified_gmt":"2016-06-09T09:54:19","slug":"clang-llvm-ir-assembly","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2015\/07\/clang-llvm-ir-assembly\/","title":{"rendered":"LLVM + clang \u3067 LLVM IR \u3084\u30a2\u30bb\u30f3\u30d6\u30ea\u3092\u51fa\u529b\u3059\u308b"},"content":{"rendered":"
clang \u306f LLVM \u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u4f7f\u7528\u3057\u3066\u304a\u308a, C\u8a00\u8a9e\u3067\u66f8\u304b\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092 LLVM IR \u306b\u51fa\u529b\u3057\u305f\u308a, \u5404\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u30a2\u30bb\u30f3\u30d6\u30ea\u3092\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u30b3\u30fc\u30c9\u751f\u6210\u3084 LLVM \u306e\u52c9\u5f37\u306b\u5229\u7528\u3067\u304d\u307e\u3059.<\/p>\n
<\/p>\n
\u3053\u3053\u3067\u306f\u5272\u611b\u3057\u307e\u3059. \u4eca\u56de\u306f LLVM \/ clang 3.6.1 \u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059.<\/p>\n
C \u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304b\u3089 LLVM IR \u3092\u51fa\u529b\u3057\u307e\u3059. C \u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304b\u3089 LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u3092\u51fa\u529b\u3057\u307e\u3059. C \u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304b\u3089\u30a2\u30bb\u30f3\u30d6\u30ea\u3092\u51fa\u529b\u3057\u307e\u3059. LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u304b\u3089 LLVM IR \u3092\u51fa\u529b\u3057\u307e\u3059. LLVM IR \u304b\u3089 LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u3092\u51fa\u529b\u3057\u307e\u3059. LLVM IR \/ \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u30a2\u30bb\u30f3\u30d6\u30ea\u3092\u51fa\u529b\u3057\u307e\u3059. clang \u306f LLVM \u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u306b\u4f7f\u7528\u3057\u3066\u304a\u308a, C\u8a00\u8a9e\u3067\u66f8\u304b\u308c\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092 LLVM IR \u306b\u51fa\u529b\u3057\u305f\u308a, \u5404\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u30a2\u30bb\u30f3\u30d6\u30ea\u3092\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u30b3\u30fc\u30c9\u751f\u6210\u3084 LLVM \u306e\u52c9\u5f37\u306b\u5229\u7528\u3067\u304d\u307e […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[81,80],"_links":{"self":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1020"}],"collection":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/comments?post=1020"}],"version-history":[{"count":9,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1020\/revisions"}],"predecessor-version":[{"id":1410,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/1020\/revisions\/1410"}],"wp:attachment":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/media?parent=1020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/categories?post=1020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/tags?post=1020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}1.ll<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b LLVM IR \u304c\u51fa\u529b\u3055\u308c\u307e\u3059.<\/p>\n
\r\nclang -c -S -emit-llvm 1.c\r\n<\/pre>\n
C -> LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9<\/h2>\n
1.bc<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u304c\u51fa\u529b\u3055\u308c\u307e\u3059.<\/p>\n
\r\nclang -c -emit-llvm 1.c \r\n<\/pre>\n
C -> \u30a2\u30bb\u30f3\u30d6\u30ea<\/h2>\n
1.s<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u30a2\u30bb\u30f3\u30d6\u30ea\u304c\u51fa\u529b\u3055\u308c\u307e\u3059. \u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f AT&T \u5f62\u5f0f\u3067\u51fa\u529b\u3055\u308c\u307e\u3059\u304c, Intel \u5f62\u5f0f\u3067\u3082\u51fa\u529b\u3067\u304d\u307e\u3059.<\/p>\n
\r\n# AT&T \u5f62\u5f0f\r\nclang -c -S 1.c\r\n# Intel \u5f62\u5f0f\r\nclang -c -S -mllvm --x86-asm-syntax=intel 1.c\r\n<\/pre>\n
LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9 -> LLVM IR<\/h2>\n
1.ll<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b LLVM IR \u304c\u51fa\u529b\u3055\u308c\u307e\u3059.<\/p>\n
\r\nllvm-dis 1.bc\r\n<\/pre>\n
LLVM IR -> LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9<\/h2>\n
1.bc<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u30d3\u30c3\u30c8\u30b3\u30fc\u30c9\u304c\u51fa\u529b\u3055\u308c\u307e\u3059.<\/p>\n
\r\nllvm-as 1.ll\r\n<\/pre>\n
LLVM IR \/ \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9 -> \u30a2\u30bb\u30f3\u30d6\u30ea<\/h2>\n
1.s<\/code> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u30a2\u30bb\u30f3\u30d6\u30ea\u304c\u51fa\u529b\u3055\u308c\u307e\u3059. \u3053\u3061\u3089\u3082 Intel \u5f62\u5f0f\u3067\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059.<\/p>\n
\r\n# LLVM IR -> AT&T \u5f62\u5f0f\r\nllc 1.ll\r\n# LLVM IR -> Intel \u5f62\u5f0f\r\nllc -x86-asm-syntax=intel 1.ll\r\n# LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9 -> AT&T \u5f62\u5f0f\r\nllc 1.bc\r\n# LLVM \u30d3\u30c3\u30c8\u30b3\u30fc\u30c9 -> Intel \u5f62\u5f0f\r\nllc -x86-asm-syntax=intel 1.bc\r\n<\/pre>\n
\u53c2\u8003<\/h2>\n
\n