<div dir="ltr">LGTM. Jakob, does this look good to commit?<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 23, 2013 at 5:23 AM, Justin Holewinski <span dir="ltr"><<a href="mailto:justin.holewinski@gmail.com" target="_blank">justin.holewinski@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Add missing test case<br>
<div class="im"><br>
<a href="http://llvm-reviews.chandlerc.com/D1128" target="_blank">http://llvm-reviews.chandlerc.com/D1128</a><br>
<br>
CHANGE SINCE LAST DIFF<br>
</div> <a href="http://llvm-reviews.chandlerc.com/D1128?vs=2947&id=2966#toc" target="_blank">http://llvm-reviews.chandlerc.com/D1128?vs=2947&id=2966#toc</a><br>
<br>
Files:<br>
test/TableGen/<a href="http://intrinsic-order.td" target="_blank">intrinsic-order.td</a><br>
utils/TableGen/IntrinsicEmitter.cpp<br>
<br>
Index: test/TableGen/<a href="http://intrinsic-order.td" target="_blank">intrinsic-order.td</a><br>
===================================================================<br>
--- /dev/null<br>
+++ test/TableGen/<a href="http://intrinsic-order.td" target="_blank">intrinsic-order.td</a><br>
@@ -0,0 +1,35 @@<br>
+// RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s<br>
+<br>
+class IntrinsicProperty;<br>
+<br>
+class ValueType<int size, int value> {<br>
+ string Namespace = "MVT";<br>
+ int Size = size;<br>
+ int Value = value;<br>
+}<br>
+<br>
+class LLVMType<ValueType vt> {<br>
+ ValueType VT = vt;<br>
+}<br>
+<br>
+class Intrinsic<string name, list<LLVMType> param_types = []> {<br>
+ string LLVMName = name;<br>
+ bit isTarget = 0;<br>
+ string TargetPrefix = "";<br>
+ list<LLVMType> RetTypes = [];<br>
+ list<LLVMType> ParamTypes = param_types;<br>
+ list<IntrinsicProperty> Properties = [];<br>
+}<br>
+<br>
+def iAny : ValueType<0, 254>;<br>
+def llvm_anyint_ty : LLVMType<iAny>;<br>
+<br>
+<br>
+// Make sure an intrinsic name that is a prefix of another is checked after the<br>
+// other.<br>
+<br>
+// CHECK: if (NameR.startswith("oo.bar.")) return Intrinsic::foo_bar;<br>
+// CHECK: if (NameR.startswith("oo.")) return Intrinsic::foo;<br>
+<br>
+def int_foo : Intrinsic<"llvm.foo", [llvm_anyint_ty]>;<br>
+def int_foo_bar : Intrinsic<"llvm.foo.bar", [llvm_anyint_ty]>;<br>
<div class="HOEnZb"><div class="h5">Index: utils/TableGen/IntrinsicEmitter.cpp<br>
===================================================================<br>
--- utils/TableGen/IntrinsicEmitter.cpp<br>
+++ utils/TableGen/IntrinsicEmitter.cpp<br>
@@ -131,6 +131,20 @@<br>
OS << "#endif\n\n";<br>
}<br>
<br>
+struct IntrinsicNameSorter {<br>
+ IntrinsicNameSorter(const std::vector<CodeGenIntrinsic> &I)<br>
+ : Ints(I) {}<br>
+<br>
+ // Sort in reverse order of intrinsic name so "abc.def" appears after<br>
+ // "abd.def.ghi" in the overridden name matcher<br>
+ bool operator()(unsigned i, unsigned j) {<br>
+ return Ints[i].Name > Ints[j].Name;<br>
+ }<br>
+<br>
+private:<br>
+ const std::vector<CodeGenIntrinsic> &Ints;<br>
+};<br>
+<br>
void IntrinsicEmitter::<br>
EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,<br>
raw_ostream &OS) {<br>
@@ -144,12 +158,16 @@<br>
OS << " StringRef NameR(Name+6, Len-6); // Skip over 'llvm.'\n";<br>
OS << " switch (Name[5]) { // Dispatch on first letter.\n";<br>
OS << " default: break;\n";<br>
+ IntrinsicNameSorter Sorter(Ints);<br>
// Emit the intrinsic matching stuff by first letter.<br>
for (std::map<char, std::vector<unsigned> >::iterator I = IntMapping.begin(),<br>
E = IntMapping.end(); I != E; ++I) {<br>
OS << " case '" << I->first << "':\n";<br>
std::vector<unsigned> &IntList = I->second;<br>
<br>
+ // Sort intrinsics in reverse order of their names<br>
+ std::sort(IntList.begin(), IntList.end(), Sorter);<br>
+<br>
// Emit all the overloaded intrinsics first, build a table of the<br>
// non-overloaded ones.<br>
std::vector<StringMatcher::StringPair> MatchTable;<br>
</div></div></blockquote></div><br></div>