llvm.org GIT mirror llvm / 041b3f8
Reverting 44702. It wasn't correct to rename them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44727 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 11 years ago
7 changed file(s) with 49 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
287287 return get(Opcode).Flags & M_HAS_OPTIONAL_DEF;
288288 }
289289
290 /// hasNoSideEffects - Return true if the instruction is trivially
290 /// isTriviallyReMaterializable - Return true if the instruction is trivially
291291 /// rematerializable, meaning it has no side effects and requires no operands
292292 /// that aren't always available.
293 bool hasNoSideEffects(MachineInstr *MI) const {
293 bool isTriviallyReMaterializable(MachineInstr *MI) const {
294294 return (MI->getInstrDescriptor()->Flags & M_REMATERIALIZIBLE) &&
295 isTriviallyReMaterializable(MI);
295 isReallyTriviallyReMaterializable(MI);
296296 }
297297
298298 protected:
299 /// isTriviallyReMaterializable - For instructions with opcodes for which the
300 /// M_REMATERIALIZABLE flag is set, this function tests whether the
301 /// instruction itself is actually trivially rematerializable, considering its
302 /// operands. This is used for targets that have instructions that are only
303 /// trivially rematerializable for specific uses. This predicate must return
304 /// false if the instruction has any side effects other than producing a
305 /// value, or if it requres any address registers that are not always
306 /// available.
307 virtual bool isTriviallyReMaterializable(MachineInstr *MI) const {
299 /// isReallyTriviallyReMaterializable - For instructions with opcodes for
300 /// which the M_REMATERIALIZABLE flag is set, this function tests whether the
301 /// instruction itself is actually trivially rematerializable, considering
302 /// its operands. This is used for targets that have instructions that are
303 /// only trivially rematerializable for specific uses. This predicate must
304 /// return false if the instruction has any side effects other than
305 /// producing a value, or if it requres any address registers that are not
306 /// always available.
307 virtual bool isReallyTriviallyReMaterializable(MachineInstr *MI) const {
308308 return true;
309309 }
310310
612612 return false;
613613
614614 isLoad = false;
615 if (tii_->hasNoSideEffects(MI)) {
615 if (tii_->isTriviallyReMaterializable(MI)) {
616616 isLoad = MI->getInstrDescriptor()->Flags & M_LOAD_FLAG;
617617 return true;
618618 }
3838 cl::desc("Perform loop-invariant code motion on machine code"));
3939 }
4040
41 STATISTIC(NumHoisted, "Number of machine instructions hoisted out of loop");
41 STATISTIC(NumHoisted, "Number of machine instructions hoisted out of loops");
4242
4343 namespace {
4444 class VISIBILITY_HIDDEN MachineLICM : public MachineFunctionPass {
9292 ///
9393 void MapVirtualRegisterDefs(const MachineFunction &MF);
9494
95 /// isInSubLoop - A little predicate that returns true if the specified
95 /// IsInSubLoop - A little predicate that returns true if the specified
9696 /// basic block is in a subloop of the current one, not the current one
9797 /// itself.
9898 ///
99 bool isInSubLoop(MachineBasicBlock *BB) {
99 bool IsInSubLoop(MachineBasicBlock *BB) {
100100 assert(CurLoop->contains(BB) && "Only valid if BB is IN the loop");
101101
102102 for (MachineLoop::iterator
119119 if (TID->ImplicitUses || !I.getNumOperands()) return false;
120120
121121 MachineOpCode Opcode = TID->Opcode;
122 return TII->hasNoSideEffects(&I) &&
122 return TII->isTriviallyReMaterializable(&I) &&
123123 // FIXME: Below necessary?
124124 !(TII->isReturn(Opcode) ||
125125 TII->isTerminatorInstr(Opcode) ||
131131 TII->isStore(Opcode));
132132 }
133133
134 /// isLoopInvariantInst - Returns true if the instruction is loop
134 /// IsLoopInvariantInst - Returns true if the instruction is loop
135135 /// invariant. I.e., all virtual register operands are defined outside of
136136 /// the loop, physical registers aren't accessed (explicitly or implicitly),
137137 /// and the instruction is hoistable.
138138 ///
139 bool isLoopInvariantInst(MachineInstr &I);
139 bool IsLoopInvariantInst(MachineInstr &I);
140140
141141 /// FindPredecessors - Get all of the predecessors of the loop that are not
142142 /// back-edges.
245245
246246 // Only need to process the contents of this block if it is not part of a
247247 // subloop (which would already have been processed).
248 if (!isInSubLoop(BB))
248 if (!IsInSubLoop(BB))
249249 for (MachineBasicBlock::iterator
250250 I = BB->begin(), E = BB->end(); I != E; ) {
251251 MachineInstr &MI = *I++;
262262 HoistRegion(Children[I]);
263263 }
264264
265 /// isLoopInvariantInst - Returns true if the instruction is loop
265 /// IsLoopInvariantInst - Returns true if the instruction is loop
266266 /// invariant. I.e., all virtual register operands are defined outside of the
267267 /// loop, physical registers aren't accessed (explicitly or implicitly), and the
268268 /// instruction is hoistable.
269269 ///
270 bool MachineLICM::isLoopInvariantInst(MachineInstr &I) {
270 bool MachineLICM::IsLoopInvariantInst(MachineInstr &I) {
271271 if (!CanHoistInst(I)) return false;
272272
273273 // The instruction is loop invariant if all of its operands are loop-invariant
299299 /// that is safe to hoist, this instruction is called to do the dirty work.
300300 ///
301301 void MachineLICM::Hoist(MachineInstr &MI) {
302 if (!isLoopInvariantInst(MI)) return;
302 if (!IsLoopInvariantInst(MI)) return;
303303
304304 std::vector Preds;
305305
315315 // the loop header.
316316 MachineBasicBlock *MBB = Preds.front();
317317
318 // FIXME: We are assuming at first that the basic blocks coming into this loop
319 // have only one successor each. This isn't the case in general because we
320 // haven't broken critical edges or added preheaders.
318 // FIXME: We are assuming at first that the basic block coming into this loop
319 // has only one successor. This isn't the case in general because we haven't
320 // broken critical edges or added preheaders.
321321 if (MBB->succ_size() != 1) return;
322322 assert(*MBB->succ_begin() == CurLoop->getHeader() &&
323323 "The predecessor doesn't feed directly into the loop header!");
115115 }
116116
117117
118 bool X86InstrInfo::isTriviallyReMaterializable(MachineInstr *MI) const {
118 bool X86InstrInfo::isReallyTriviallyReMaterializable(MachineInstr *MI) const {
119119 switch (MI->getOpcode()) {
120120 default: break;
121121 case X86::MOV8rm:
238238 unsigned& destReg) const;
239239 unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const;
240240 unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const;
241 bool isTriviallyReMaterializable(MachineInstr *MI) const;
241 bool isReallyTriviallyReMaterializable(MachineInstr *MI) const;
242242
243243 /// convertToThreeAddress - This method must be implemented by targets that
244244 /// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
1515 llc llvm-ranlib llvm-ar llvm-nm \
1616 llvm-ld llvmc llvm-prof llvm-link \
1717 lli gccas gccld llvm-extract llvm-db llvm2cpp \
18 bugpoint llvm-bcanalyzer llvm-stub
19
18 bugpoint llvm-bcanalyzer llvm-stub cfe
19
2020
2121 include $(LEVEL)/Makefile.config
2222
1515
1616 (defvar tablegen-font-lock-keywords
1717 (let ((kw (mapconcat 'identity
18 '("class" "def" "defm" "field" "in" "include"
18 '("class" "defm" "def" "field" "include" "in"
1919 "let" "multiclass")
2020 "\\|"))
2121 (type-kw (mapconcat 'identity
4848
4949 ;; ---------------------- Syntax table ---------------------------
5050 ;; Shamelessly ripped from jasmin.el
51 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
51 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el
5252
5353 (if (not tablegen-mode-syntax-table)
5454 (progn
5555 (setq tablegen-mode-syntax-table (make-syntax-table))
56 (mapcar (function (lambda (n)
57 (modify-syntax-entry (aref n 0)
58 (aref n 1)
59 tablegen-mode-syntax-table)))
56 (mapcar (function
57 (lambda (n)
58 (modify-syntax-entry (aref n 0)
59 (aref n 1)
60 tablegen-mode-syntax-table)))
6061 '(
6162 ;; whitespace (` ')
6263 [?\^m " "]
6566 [?\t " "]
6667 [?\ " "]
6768 ;; word constituents (`w')
68 ;;[?< "w"]
69 ;;[?> "w"]
7069 [?\% "w"]
7170 ;;[?_ "w "]
7271 ;; comments
7776 ;; symbol constituents (`_')
7877 ;; punctuation (`.')
7978 ;; open paren (`(')
80 [?\( "("]
81 [?\[ "("]
82 [?\{ "("]
79 [?\( "("]
80 [?\[ "("]
81 [?\{ "("]
82 [?\< "("]
8383 ;; close paren (`)')
84 [?\) ")"]
85 [?\] ")"]
86 [?\} ")"]
84 [?\) ")"]
85 [?\] ")"]
86 [?\} ")"]
87 [?\> ")"]
8788 ;; string quote ('"')
88 [?\" "\""]
89 [?\" "\""]
8990 ))))
9091
9192 ;; --------------------- Abbrev table -----------------------------
100101 (if (not tablegen-mode-map)
101102 () ; Do not change the keymap if it is already set up.
102103 (setq tablegen-mode-map (make-sparse-keymap))
103 (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
104 (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
104105 (define-key tablegen-mode-map "\es" 'center-line)
105106 (define-key tablegen-mode-map "\eS" 'center-paragraph))
106
107107
108108 (defun tablegen-mode ()
109109 "Major mode for editing TableGen description files.
114114 (use-local-map tablegen-mode-map) ; Provides the local keymap.
115115 (setq major-mode 'tablegen-mode)
116116
117 (make-local-variable 'font-lock-defaults)
117 (make-local-variable 'font-lock-defaults)
118118 (setq major-mode 'tablegen-mode ; This is how describe-mode
119119 ; finds the doc string to print.
120 mode-name "TableGen" ; This name goes into the modeline.
120 mode-name "TableGen" ; This name goes into the modeline.
121121 font-lock-defaults `(tablegen-font-lock-keywords))
122122
123123 (setq local-abbrev-table tablegen-mode-abbrev-table)