<div dir="ltr"><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">This patch is used to add ‘bhsd’ suffix in Neon ACLE scalar function name.</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">1. A new type prefix ‘S’ is defined in tools/clang/include/clang/Basic/<a href="http://arm_neon.td">arm_neon.td</a>, which is used to mark whether enable ‘bhsd’ suffix mangle.</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">2. If prefix ‘S’ is found before data type, proper suffix will be added according below rule:</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">Data Type  Suffix</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0);text-indent:10.5pt">
<span lang="EN-US">i8 -> b</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0);text-indent:10.5pt"><span lang="EN-US">i16 -> h</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0);text-indent:10.5pt"><span lang="EN-US">i32 f32 -> s</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0);text-indent:10.5pt">
<span lang="EN-US">i64 f64 -> d</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">For example,</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">If we define a new ACLE function in <a href="http://arm_neon.td">arm_neon.td</a> like:</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">def FABD : SInst<”vabd”, “sss”,  “ScSsSiSlSfSd”></span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">Then, rebuild llvm. We would see below in INSTALL_PATH/lib/clang/3.4/include/arm_neon.h</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">__ai int8_t vabdb_s8(int8_t __a, int8_t __b) {</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">  return (int8_t)__builtin_neon_vabdb_s8(__a, __b); }</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">__ai int16_t vabdh_s16(int16_t __a, int16_t __b) {</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">  return (int16_t)__builtin_neon_vabdh_s8(__a, __b); }</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span style="font-family:ËÎÌå">…</span><span lang="EN-US"></span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">Proper suffix is inserted in both ACLE intrinsics and builtin functions.</span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US">Because this patch only works on llvm building time, so I have no idea on writing test case for this patch. Fortunately, this patch won’t effect on any already defined ACLE functions, for its function depending on the new defined prefix ‘S’. So It is safe for current system and is developed to help implement new scalar ACLE intrinsics in parallel.</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p><p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<span lang="EN-US">You can see each scalar ACLE function corresponds to an unique builtin function. At beginning, I planned to let series of ACLE functions with the same semantics reuse one builtin function. But this would introduce extra unnecessary convert expression in IR, for different data types have different data width. If I promote all data types to i64 and use single builtin function, then there will be only an i64 version builtin function existing in IR. Though I can add extra arg in builtin function to record the original data type, but extra data convert IR(sign extension before call and truncation after call) still exists. This will increase the difficulty in coding lower patterns in backend.</span></p>
<p class="" style="margin:0cm 0cm 0.0001pt;text-align:justify;font-size:14px;font-family:Calibri,sans-serif;color:rgb(0,0,0)"><span lang="EN-US"> </span></p></div>