<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">YOu have to look for which DAG
fragments are not being matched.<br>
<br>
Then you can create patterns for those using alternate sequences.<br>
<br>
When you disablea given instruction, don't just disable it, but
also look at what pattern it was matching.<br>
<br>
Then create a patten for that using remaining instructions or in
some cases you might have to call a library function, as in the
case of floating pointing or maybe even integer multiply if you
don't implement that.<br>
<br>
In some cases, the original instruction may be directly emitted by
the compiler, outside of the framework td files. Then you'll have
to modify c++ code and emit an alternate sequence.<br>
<br>
Here are some simple patterns from the MipsInstrInfo.td<br>
<br>
//===----------------------------------------------------------------------===//<br>
// Arbitrary patterns that map to one or more instructions<br>
//===----------------------------------------------------------------------===//<br>
<br>
// Small immediates<br>
def : MipsPat<(i32 immSExt16:$in),<br>
(ADDiu ZERO, imm:$in)>;<br>
def : MipsPat<(i32 immZExt16:$in),<br>
(ORi ZERO, imm:$in)>;<br>
def : MipsPat<(i32 immLow16Zero:$in),<br>
(LUi (HI16 imm:$in))>;<br>
<br>
Here are some which have several instructions<br>
<br>
multiclass SetgePats<RegisterClass RC, Instruction SLTOp,
Instruction SLTuOp> {<br>
def : MipsPat<(setge RC:$lhs, RC:$rhs),<br>
(XORi (SLTOp RC:$lhs, RC:$rhs), 1)>;<br>
def : MipsPat<(setuge RC:$lhs, RC:$rhs),<br>
(XORi (SLTuOp RC:$lhs, RC:$rhs), 1)>;<br>
}<br>
<br>
<br>
On 07/20/2012 07:20 AM, Geraint Yang wrote:<br>
</div>
<blockquote
cite="mid:CAAdM-RUVLnqVD8ugaQn_f59qZeTf+JUsK+V8FqG4+M=E3DWOfA@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Thanks for your reply.<br>
<br>
We are trying to implement a simple Mips-based CPU with just for
teaching purpose, so we delete some instructions which are not
commonly used, thus the task won't be too hard for students. I am
responsible for modifying the compiler so that the compiler won't
emit unsupported instructions.<br>
<br>
In order to avoid "can not select" error, I am trying to expand
these instructions when meeting them.<br>
<br>
So what should I modify to achieve the goal?<br>
<br>
<br>
Thanks,<br>
Yang<br>
<br>
<br>
<div class="gmail_quote">
On Fri, Jul 20, 2012 at 10:02 PM, Reed Kotler <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:rkotler@mips.com"
target="_blank">rkotler@mips.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>why do you want to "ban" certain instructions?<br>
<br>
is this for some architectural variant?<br>
<br>
the compiler is trying to match patterns from the target
independent part of the code generator.<br>
<br>
if you remove instructions, the compiler in many cases
will no longer be able to match certain patterns<br>
and you will get thos "can not select" messages.
<div>
<div class="h5"><br>
<br>
On 07/20/2012 03:05 AM, Geraint Yang wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5"> Hi everyone,<br>
<br>
<font>I am a newbie to LLVM. I am trying to ban some
of instructions in Mips Instruction, for example,
lh, lhu, sh, and etc.<br>
I have tried to </font><font>directly comment lh,
lhu, and sh to make llvm not to choose these
instruction when compiling, however, it usually
cause a 'can not select ...' error when using
'short' data type in source code.<br>
Then I tried to expand these instructions in</font>
EmitInstrWithCustomInserter in file <font>lib/Target/Mips/MipsISelLowering.cpp,
just as commit in:<br>
<br>
<a moz-do-not-send="true"
href="https://github.com/geraint0923/LLVM-ThuMips/commit/6a9ca907f3e945c2bb1f9627e0e5fdcbd7964da2"
target="_blank">https://github.com/geraint0923/LLVM-ThuMips/commit/6a9ca907f3e945c2bb1f9627e0e5fdcbd7964da2</a><br>
<br>
It works fine for lh and lhu, and fails for sh:<br>
when expanding sh, there are four instruction, but
in *.s generated by modified llvm's llc, there are
only two instructions which are both sb, addiu and
srl are gone.<br>
<br>
Is there anything wrong when expanding? <br>
And I wonder if there is another method to do the
same thing.<br>
<br>
Any help will be appreciated.</font><br>
<br>
<br>
Thanks,<br>
Yang <br>
<fieldset></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div style="text-align:left">Geraint Yang <br>
Tsinghua University Department of Computer Science and
Technology</div>
<div><br>
</div>
<br>
</blockquote>
<br>
</body>
</html>