[llvm-commits] [llvm] r168810 - in /llvm/trunk/lib/Target/Hexagon: HexagonISelDAGToDAG.cpp HexagonOperands.td

Jyotsna Verma jverma at codeaurora.org
Thu Nov 29 09:01:06 PST 2012


Thanks Anshu for the suggestion.

I'll fix it in the next patch.

 

-Jyotsna

 

--

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation

 

From: Anshuman Dasgupta [mailto:adasgupt at codeaurora.org] 
Sent: Thursday, November 29, 2012 9:29 AM
To: Jyotsna Verma
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [llvm] r168810 - in
/llvm/trunk/lib/Target/Hexagon: HexagonISelDAGToDAG.cpp HexagonOperands.td

 

Jyotsna,
 
> +bool HexagonDAGToDAGISel::isConstExtProfitable(SDNode *N) const {
> +  unsigned UseCount = 0;
> +  for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E;
++I) {
> +    UseCount++;
> +  }
+  return (UseCount <= 1);
 
 
This part should be simplified to:
---
return (N->use_empty() || N->hasOneUse());
---

You don't have to change this immediately but please work it in to your next
set of cleanup patches.

(Also, no braces for a single statement for loop but the loop will go away
in any case.)

Thanks
-Anshu

---
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by
The Linux Foundation




On 11/28/2012 2:58 PM, Jyotsna Verma wrote:

Author: jverma
Date: Wed Nov 28 14:58:14 2012
New Revision: 168810
 
URL: http://llvm.org/viewvc/llvm-project?rev=168810
<http://llvm.org/viewvc/llvm-project?rev=168810&view=rev> &view=rev
Log:
Define signed const-ext immediate operands and their predicates.
 
Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
    llvm/trunk/lib/Target/Hexagon/HexagonOperands.td
 
Modified: llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonISe
lDAGToDAG.cpp?rev=168810
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonIS
elDAGToDAG.cpp?rev=168810&r1=168809&r2=168810&view=diff>
&r1=168809&r2=168810&view=diff
============================================================================
==
--- llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp Wed Nov 28
14:58:14 2012
@@ -94,6 +94,7 @@
   SDNode *SelectConstant(SDNode *N);
   SDNode *SelectConstantFP(SDNode *N);
   SDNode *SelectAdd(SDNode *N);
+  bool isConstExtProfitable(SDNode *N) const;
 
   // Include the pieces autogenerated from the target description.
 #include "HexagonGenDAGISel.inc"
@@ -1507,3 +1508,13 @@
   OutOps.push_back(Op1);
   return false;
 }
+
+bool HexagonDAGToDAGISel::isConstExtProfitable(SDNode *N) const {
+  unsigned UseCount = 0;
+  for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E;
++I) {
+    UseCount++;
+  }
+
+  return (UseCount <= 1);
+
+}
 
Modified: llvm/trunk/lib/Target/Hexagon/HexagonOperands.td
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonOpe
rands.td?rev=168810
<http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonOp
erands.td?rev=168810&r1=168809&r2=168810&view=diff>
&r1=168809&r2=168810&view=diff
============================================================================
==
--- llvm/trunk/lib/Target/Hexagon/HexagonOperands.td (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonOperands.td Wed Nov 28 14:58:14
2012
@@ -465,3 +465,114 @@
   int8_t v = (int8_t)N->getSExtValue();
   return (v >= 0 && v <= 7);
 }]>;
+
+
+// Extendable immediate operands.
+
+let PrintMethod = "printExtOperand" in {
+  def s16Ext : Operand<i32>;
+  def s12Ext : Operand<i32>;
+  def s10Ext : Operand<i32>;
+  def s9Ext : Operand<i32>;
+  def s8Ext : Operand<i32>;
+  def s6Ext : Operand<i32>;
+  def s11_0Ext : Operand<i32>;
+  def s11_1Ext : Operand<i32>;
+  def s11_2Ext : Operand<i32>;
+  def s11_3Ext : Operand<i32>;
+}
+
+let PrintMethod = "printImmOperand" in
+def u0AlwaysExt : Operand<i32>;
+
+// Predicates for constant extendable operands
+def s16ExtPred  : PatLeaf<(i32 imm), [{
+  int64_t v = (int64_t)N->getSExtValue();
+  if (!Subtarget.hasV4TOps())
+    // Return true if the immediate can fit in a 16-bit sign extended
field.
+    return isInt<16>(v);
+  else {
+    if (isInt<16>(v))
+      return true;
+
+    // Return true if extending this immediate is profitable and the value
+    // can fit in a 32-bit signed field.
+    if (isConstExtProfitable(Node) && isInt<32>(v))
+      return true;
+    else
+      return false;
+  }
+}]>;
+
+def s10ExtPred  : PatLeaf<(i32 imm), [{
+  int64_t v = (int64_t)N->getSExtValue();
+  if (!Subtarget.hasV4TOps())
+    // Return true if the immediate can fit in a 10-bit sign extended
field.
+    return isInt<10>(v);
+  else {
+    if (isInt<10>(v))
+      return true;
+
+    // Return true if extending this immediate is profitable and the value
+    // can fit in a 32-bit signed field.
+    if (isConstExtProfitable(Node) && isInt<32>(v))
+      return true;
+    else
+      return false;
+  }
+}]>;
+
+def s9ExtPred  : PatLeaf<(i32 imm), [{
+  int64_t v = (int64_t)N->getSExtValue();
+  if (!Subtarget.hasV4TOps())
+    // Return true if the immediate can fit in a 9-bit sign extended field.
+    return isInt<9>(v);
+  else {
+    if (isInt<9>(v))
+      return true;
+
+    // Return true if extending this immediate is profitable and the value
+    // can fit in a 32-bit unsigned field.
+    if (isConstExtProfitable(Node) && isInt<32>(v))
+      return true;
+    else
+      return false;
+  }
+}]>;
+
+def s8ExtPred  : PatLeaf<(i32 imm), [{
+  int64_t v = (int64_t)N->getSExtValue();
+  if (!Subtarget.hasV4TOps())
+    // Return true if the immediate can fit in a 8-bit sign extended field.
+    return isInt<8>(v);
+  else {
+    if (isInt<8>(v))
+      return true;
+
+    // Return true if extending this immediate is profitable and the value
+    // can fit in a 32-bit signed field.
+    if (isConstExtProfitable(Node) && isInt<32>(v))
+      return true;
+    else
+      return false;
+  }
+}]>;
+
+def s8_16ExtPred  : PatLeaf<(i32 imm), [{
+  int64_t v = (int64_t)N->getSExtValue();
+  if (!Subtarget.hasV4TOps())
+    // Return true if the immediate fits in a 8-bit sign extended field.
+    return isInt<8>(v);
+  else {
+    if (isInt<8>(v))
+      return true;
+
+    // Return true if extending this immediate is profitable and the value
+    // can't fit in a 16-bit signed field. This is required to avoid
+    // unnecessary constant extenders.
+    if (isConstExtProfitable(Node) && !isInt<16>(v))
+      return true;
+    else
+      return false;
+  }
+}]>;
 
 
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121129/bbcdeb5d/attachment.html>


More information about the llvm-commits mailing list