search for: getnumoperands

Displaying 20 results from an estimated 245 matches for "getnumoperands".

2010 Feb 03
1
[LLVMdev] MI.getNumOperands() < MI.getDesc().getNumOperands()
With a modified copy of LLVM (so it's probably my fault) I'm getting an assertion failure because isTwoAddrUse (in TwoAddressInstructionPass.cpp) is being called with a MachineInstr MI such that MI.getNumOperands() is 2, but MI.getDesc().getNumOperands() is 5. The assertion fails when that function calls MI.getOperand(2). My question is: is isTwoAddrUse doing the right thing here? static bool isTwoAddrUse(MachineInstr &MI, unsigned Reg, unsigned &DstReg) { const TargetInstrDesc &TID = MI.get...
2019 May 29
2
Problem of getNumOperands() for CallInst
Hi all, I got a interesting problem when calling getNumOperands() of CallInst. For example, call void @_Z2f2PA100_i([100 x i32]* nonnull %arraydecay) If I use getNumOperands(), it will return 2. However, if I use getCalledFunction()->getNumParams(), it will return 1. According to the IR, I think the number of operands of the call...
2019 Mar 16
2
Why getNumOperands() incorrectly returns 0?
...t function correctly e.g.: ; Function Attrs: nounwind uwtable define void @png_set_mem_fn(%struct.png_struct_def.68* noalias %png_ptr, i8* %mem_ptr, i8* (%struct.png_struct_def.68*, i64)* %malloc_fn, void (%struct.png_struct_def.68*, i8*)* %free_fn) #5 { ... } The problem is that when I do F->getNumOperands() I have 0 as result. Can you explain me why please? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190316/4375e976/attachment.html>
2010 Jul 16
2
[LLVMdev] Strange behavior when converting arrays to strings
...t arrays to strings. Consider the following example: std::string Text = "HelloWorld"; unsigned TextLengthBefore = Text.length(); ConstantArray *pArray = dyn_cast<ConstantArray>(llvm::ConstantArray::get(pModule->getContext(), Text, true)); unsigned NumElements = pArray->getNumOperands(); Text = pArray->getAsString(); unsigned TextLengthAfter = Text.length(); After running this example here are the values in each variable: TextLengthBefore = 10 NumElements = 11 TextLengthAfter = 11 In the conversion from constant array to a string the null terminating character is...
2011 Oct 07
3
[LLVMdev] VirtRegRewriter.cpp: LocalRewriter::ProcessUses()
...k I've found a bug in this method. I ran it on an MI which already had two implicit-use operands, and which defined a register with a subregindex, ie reg::lo16. For the def-operand, with a subregindex, an implicit-use operand was added with this code: VirtUseOps.insert(VirtUseOps.begin(), MI.getNumOperands()); MI.addOperand(MachineOperand::CreateReg(VirtReg, false, // isDef true)); // isImplicit As, can be seen, it is presumed that this operand is always the last operand, this is however not the case. It i...
2011 Jan 04
4
[LLVMdev] Bug in MachineInstr::isIdenticalTo
...=============== --- MachineInstr.cpp (revision 122820) +++ MachineInstr.cpp (working copy) @@ -761,9 +761,23 @@ // If opcodes or number of operands are not the same then the two // instructions are obviously not identical. if (Other->getOpcode() != getOpcode() || - Other->getNumOperands() != getNumOperands()) + Other->getNumOperands() != getNumOperands() || + Other->memoperands_empty() != memoperands_empty()) return false; + if (!memoperands_empty()) { + // If we have mem operands, make sure that the sizes of the memoperands for each + // MI are the sam...
2011 Jan 04
0
[LLVMdev] Bug in MachineInstr::isIdenticalTo
...tr.cpp (revision 122820) > +++ MachineInstr.cpp (working copy) > @@ -761,9 +761,23 @@ > // If opcodes or number of operands are not the same then the two > // instructions are obviously not identical. > if (Other->getOpcode() != getOpcode() || > - Other->getNumOperands() != getNumOperands()) > + Other->getNumOperands() != getNumOperands() || > + Other->memoperands_empty() != memoperands_empty()) > return false; > + if (!memoperands_empty()) { > + // If we have mem operands, make sure that the sizes of the memoperands for ea...
2010 Jul 28
0
[LLVMdev] Strange behavior when converting arrays to strings
...t arrays to strings. Consider the following example: std::string Text = "HelloWorld"; unsigned TextLengthBefore = Text.length(); ConstantArray *pArray = dyn_cast<ConstantArray>(llvm::ConstantArray::get(pModule->getContext(), Text, true)); unsigned NumElements = pArray->getNumOperands(); Text = pArray->getAsString(); unsigned TextLengthAfter = Text.length(); After running this example here are the values in each variable: TextLengthBefore = 10 NumElements = 11 TextLengthAfter = 11 In the conversion from constant array to a string the null terminating character is...
2010 Jul 28
1
[LLVMdev] Strange behavior when converting arrays to strings
...e situations /// this is not desired so if AddNull==false then the string is copied without /// null termination. static Constant *get(LLVMContext &Context, StringRef Initializer, bool AddNull = true); Ciao, Duncan. > > unsigned NumElements = pArray->getNumOperands(); > > Text = pArray->getAsString(); > > unsigned TextLengthAfter = Text.length(); > > After running this example here are the values in each variable: > > TextLengthBefore = 10 > > NumElements = 11 > > TextLengthAfter = 11 > > In the conversion from con...
2013 Jan 10
2
[LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP
...rom every basic block in runOnFunction(). I am interested in ICMP instructions only. if(BB->size()>1) if(last->getPrevNode()) { previous = last->getPrevNode(); ok=1; } I want to get the operands of previous, which is of type Instruction*. Due tests based on getNumOperands, ICMP has 2 (as normal). if ( ok && ((previous->getNumOperands())>=2) ) errs()<<"\nTTTTT "<<previous->getOperand(0)->getName()<<" | " <<previous->getOperand(0)->getValueName()<<" | " <...
2014 Jan 21
3
[LLVMdev] MergeFunctions: reduce complexity to O(log(N))
...red through (e.g., at the beginning of FunctionComparator::cmpConstants). - Your new helper functions (such as cmpNumbers) that are local to the file should be declared 'static'. - You use the following pattern throughout: int Res; // ... Res = cmpNumbers(I1->getNumOperands(), I2->getNumOperands()); if (Res != 0) return Res; whereas, since you never use Res unless it's non-zero, I think the following is more clear and concise: if (int Res = cmpNumbers(I1->getNumOperands(), I2->getNumOperands())) return R...
2011 Oct 12
0
[LLVMdev] VirtRegRewriter.cpp: LocalRewriter::ProcessUses()
...method. > > I ran it on an MI which already had two implicit-use operands, and which defined a register with a subregindex, ie reg::lo16. > > For the def-operand, with a subregindex, an implicit-use operand was added with this code: > > VirtUseOps.insert(VirtUseOps.begin(), MI.getNumOperands()); > MI.addOperand(MachineOperand::CreateReg(VirtReg, > false, // isDef > true)); // isImplicit > > As, can be seen, it is presumed that this operand is always the last operand, this is h...
2004 Feb 20
1
[LLVMdev] Changes in MachineInstruction/Peephole Optimizer?
...pholeOptimizer.cpp: line 70: case X86::ADDri16: case X86::ADDri32: case X86::SUBri16: case X86::SUBri32: case X86::IMULri16: case X86::IMULri32: case X86::ANDri16: case X86::ANDri32: case X86::ORri16: case X86::ORri32: case X86::XORri16: case X86::XORri32: assert(MI->getNumOperands() == 3 && "These should all have 3 operands!"); While in the LLVM cvs version, PeepholeOptimizer, line 123: case X86::ADDri16: case X86::ADDri32: case X86::SUBri16: case X86::SUBri32: case X86::ANDri16: case X86::ANDri32: case X86::ORri16: case X86::ORri32:...
2005 Jul 29
0
[LLVMdev] patch for pointer-to-array conversion
...d loop!"); - unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader); - unsigned BackedgeIdx = PreheaderIdx^1; - if (GetElementPtrInst *GEPI = - dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx))) - if (GEPI->getOperand(0) == PN) { - assert(GEPI->getNumOperands() == 2 && "GEP types must mismatch!"); - +static std::pair<Value*,Value*> transformPointerRecurrence( + GetElementPtrInst *GEPI, PHINode *PN, BasicBlock *Preheader ) +{ + unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader); + unsigned Backed...
2013 Jan 10
0
[LLVMdev] LLVM Instruction*->getOperand() not working properly for ICMP
...ICMP instructions only. > > |if(BB->size()>1) > if(last->getPrevNode()) > { > previous = last->getPrevNode(); > ok=1; > } > | > > I want to get the operands of previous, which is of type Instruction*. Due tests > based on getNumOperands, ICMP has 2 (as normal). > > |if ( ok && ((previous->getNumOperands())>=2) ) > > errs()<<"\nTTTTT "<<previous->getOperand(0)->getName()<<" | " > <<previous->getOperand(0)->getValueName()<<&quo...
2005 Jul 30
1
[LLVMdev] Iterator to enumerate machine operands
...hine instruction, but the iterator seems to skip everything except virtual registers. Is this by design? MachineInstr.h <code> template<class MITy, class VTy> class ValOpIterator : public forward_iterator<VTy, ptrdiff_t> { void skipToNextVal() { while (i < MI->getNumOperands() && !( (MI->getOperand(i).getType() == MachineOperand::MO_VirtualRegister || MI->getOperand(i).getType() == MachineOperand::MO_CCRegister) && MI->getOperand(i).getVRegValue() != 0)) ++i; } </code> -- Tzu-Chi...
2012 Dec 26
0
[LLVMdev] Getting MCInst "ins" and "outs"
The MCInstrDesc has a method getNumDefs() which tells you how many 'out registers' that MCInst has. The 'out' registers are always at the beginning of the list. You can also use getNumOperands(). Not sure if this is what you are looking for. -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Vladimir Pouzanov Sent: Sunday, December 23, 2012 3:35 PM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] Getting MCInst "ins&q...
2011 Sep 26
1
[LLVMdev] distinguishing between real arguments and variable arguments
...new call instructions and then have a subtle delay slot bug. Any suggestions on how to fix LLVM so that we can get the non variable operands? In Mblaze: static unsigned getLastRealOperand(MachineBasicBlock::iterator &instr) { switch (instr->getOpcode()) { default: return instr->getNumOperands(); // These instructions have a variable number of operands but the first two // are the "real" operands that we care about during hazard detection. case MBlaze::BRLID: case MBlaze::BRALID: case MBlaze::BRLD: case MBlaze::BRALD: return 2; } } In Sparc: void F...
2009 May 20
2
[LLVMdev] [PATCH] Add new phase to legalization to handle vector operations
...+ MVT VT = Op.getValueType(); + assert(Op.getNode()->getNumValues() == 1 && + "Can't promote a vector with multiple results!"); + MVT NVT = TLI.getTypeToPromoteTo(Op.getOpcode(), VT); + DebugLoc dl = Op.getDebugLoc(); + SmallVector<SDValue, 4> Operands(Op.getNumOperands()); + + for (unsigned j = 0; j != Op.getNumOperands(); ++j) { + if (Op.getOperand(j).getValueType().isVector()) + Operands[j] = DAG.getNode(ISD::BIT_CONVERT, dl, NVT, Op.getOperand(j)); + else + Operands[j] = Op.getOperand(j); + } + + Op = DAG.getNode(Op.getOpcode(), dl, NVT, &am...
2016 Nov 27
5
Extending Register Rematerialization
...unsigned int depth, AliasAnalysis *aa) { if(TII.isReMaterializablePossible(*DefMI, aa)) return false; DEBUG(dbgs() << " ComplexRemat MI: " << *DefMI); for (unsigned i = 0, e = DefMI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = DefMI->getOperand(i); if (!MO.isReg() || !MO.getReg() || !MO.readsReg()) continue; if (TargetRegisterInfo::isPhysicalRegister(MO.getReg())) { if (MRI.isConstantPhysReg(MO.getReg(), *DefMI->getParent()->getParent()))...