{"id":6352,"date":"2017-02-20T23:40:52","date_gmt":"2017-02-20T14:40:52","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6352"},"modified":"2017-02-21T23:40:39","modified_gmt":"2017-02-21T14:40:39","slug":"clang-%e3%81%ae%e3%82%a4%e3%83%b3%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%a2%e3%82%bb%e3%83%b3%e3%83%96%e3%83%a9%e3%81%af-asm-%e5%8f%a5%e3%82%92%e3%81%be%e3%81%9f%e3%81%84%e3%81%a0%e3%83%9e%e3%82%af%e3%83%ad","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=6352","title":{"rendered":"Clang \u306e\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u306f\u5225\u306e asm \u53e5\u5185\u306b\u3042\u308b\u30de\u30af\u30ed\u3092\u51e6\u7406\u3067\u304d\u306a\u3044"},"content":{"rendered":"<p>\u540c\u4e00 asm \u53e5\u5185\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u5834\u5408\u306f\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u5225\u306e asm \u53e5\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u3068\u51e6\u7406\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u540c\u4e00 asm \u53e5\u5185\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u5834\u5408<\/p>\n<blockquote>\n<pre>[umezawa@metis:ttys000 ~]$ cat macro1.c\r\nint main(int argc, char** argv)\r\n{\r\n        asm volatile(\r\n                \".macro THENOP\\n\"\r\n                \"nop\\n\"\r\n                \".endm\\n\"\r\n                \"THENOP\":);\r\n        return 0;\r\n}\r\n[umezawa@metis:ttys000 ~]$ clang -S -o- macro1.c\r\n        .section        __TEXT,__text,regular,pure_instructions\r\n        .macosx_version_min 10, 12\r\n        .globl  _main\r\n        .align  4, 0x90\r\n_main:                                  ## @main\r\n        .cfi_startproc\r\n## BB#0:\r\n        pushq   %rbp\r\nLtmp0:\r\n        .cfi_def_cfa_offset 16\r\nLtmp1:\r\n        .cfi_offset %rbp, -16\r\n        movq    %rsp, %rbp\r\nLtmp2:\r\n        .cfi_def_cfa_register %rbp\r\n        movl    $0, -4(%rbp)\r\n        movl    %edi, -8(%rbp)\r\n        movq    %rsi, -16(%rbp)\r\n        ## InlineAsm Start\r\n\r\n        nop\r\n\r\n        ## InlineAsm End\r\n        xorl    %eax, %eax\r\n        popq    %rbp\r\n        retq\r\n        .cfi_endproc\r\n\r\n\r\n.subsections_via_symbols\r\n<\/pre>\n<\/blockquote>\n<p>\u5225\u306e asm \u53e5\u5185\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u5834\u5408<\/p>\n<blockquote>\n<pre>\r\n[umezawa@metis:ttys000 ~]$ cat macro2.c\r\nint main(int argc, char** argv)\r\n{\r\n        asm volatile(\r\n                \".macro THENOP\\n\"\r\n                \"nop\\n\"\r\n                \".endm\\n\":);\r\n        asm volatile(\r\n                \"THENOP\":);\r\n        return 0;\r\n}\r\n[umezawa@metis:ttys000 ~]$ clang -c macro2.c\r\nmacro2.c:8:3: error: invalid instruction mnemonic 'thenop'\r\n                \"THENOP\":);\r\n                ^\r\n<inline asm>:1:2: note: instantiated into assembly here\r\n        THENOP\r\n        ^~~~~~\r\n1 error generated.\r\n<\/inline><\/pre>\n<\/blockquote>\n<p>\u3053\u308c\u3067\u4f55\u304c\u56f0\u308b\u304b\u3068\u8a00\u3046\u3068\u3001\u8907\u6570\u306e\u95a2\u6570\u5185\u3067\u4f7f\u3044\u305f\u3044\u30de\u30af\u30ed\u3092\u8a18\u8ff0\u3067\u304d\u306a\u3044\u308f\u3051\u3067\u3059\u3002\u3082\u3046 Clang \u3067\u30a4\u30f3\u30e9\u30a4\u30f3\u30a2\u30bb\u30f3\u30d6\u30e9\u3092\u4f7f\u304a\u3046\u3068\u3059\u308b\u306e\u306f\u3084\u3081\u3068\u3044\u305f\u65b9\u304c\u3044\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u3044\u3046\u6c17\u304c\u3057\u3066\u304f\u308b\u3002<\/p>\n<p>\u3088\u304f\u3082\u307e\u3042\u3053\u3093\u306a\u72b6\u614b\u3067 &#8220;In general, Clang is highly compatible with the GCC inline assembly extensions&#8221; \u306a\u3069\u3068\uff08\uff52\uff59<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u4e00 asm \u53e5\u5185\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u5834\u5408\u306f\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u5225\u306e asm \u53e5\u306b\u5b9a\u7fa9\u304c\u3042\u308b\u3068\u51e6\u7406\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-6352","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6352"}],"version-history":[{"count":4,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6352\/revisions"}],"predecessor-version":[{"id":6357,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6352\/revisions\/6357"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6352"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}