Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/IceInst.h

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: doesn't matter if eax or not Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===// 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares the Inst class and its target-independent 10 // This file declares the Inst class and its target-independent
11 // subclasses, which represent the high-level Vanilla ICE instructions 11 // subclasses, which represent the high-level Vanilla ICE instructions
12 // and map roughly 1:1 to LLVM instructions. 12 // and map roughly 1:1 to LLVM instructions.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #ifndef SUBZERO_SRC_ICEINST_H 16 #ifndef SUBZERO_SRC_ICEINST_H
17 #define SUBZERO_SRC_ICEINST_H 17 #define SUBZERO_SRC_ICEINST_H
18 18
19 #include "IceDefs.h" 19 #include "IceDefs.h"
20 #include "IceInst.def" 20 #include "IceInst.def"
21 #include "IceIntrinsics.h"
21 #include "IceTypes.h" 22 #include "IceTypes.h"
22 23
23 // TODO: The Cfg structure, and instructions in particular, need to be 24 // TODO: The Cfg structure, and instructions in particular, need to be
24 // validated for things like valid operand types, valid branch 25 // validated for things like valid operand types, valid branch
25 // targets, proper ordering of Phi and non-Phi instructions, etc. 26 // targets, proper ordering of Phi and non-Phi instructions, etc.
26 // Most of the validity checking will be done in the bitcode reader. 27 // Most of the validity checking will be done in the bitcode reader.
27 // We need a list of everything that should be validated, and tests 28 // We need a list of everything that should be validated, and tests
28 // for each. 29 // for each.
29 30
30 namespace Ice { 31 namespace Ice {
31 32
32 class Inst { 33 class Inst {
33 public: 34 public:
34 enum InstKind { 35 enum InstKind {
35 // Arbitrary (alphabetical) order, except put Unreachable first. 36 // Arbitrary (alphabetical) order, except put Unreachable first.
36 Unreachable, 37 Unreachable,
37 Alloca, 38 Alloca,
38 Arithmetic, 39 Arithmetic,
39 Assign, // not part of LLVM/PNaCl bitcode 40 Assign, // not part of LLVM/PNaCl bitcode
40 Br, 41 Br,
41 Call, 42 Call,
42 Cast, 43 Cast,
43 Fcmp, 44 Fcmp,
44 Icmp, 45 Icmp,
46 IntrinsicCall,
45 Load, 47 Load,
46 Phi, 48 Phi,
47 Ret, 49 Ret,
48 Select, 50 Select,
49 Store, 51 Store,
50 Switch, 52 Switch,
51 FakeDef, // not part of LLVM/PNaCl bitcode 53 FakeDef, // not part of LLVM/PNaCl bitcode
52 FakeUse, // not part of LLVM/PNaCl bitcode 54 FakeUse, // not part of LLVM/PNaCl bitcode
53 FakeKill, // not part of LLVM/PNaCl bitcode 55 FakeKill, // not part of LLVM/PNaCl bitcode
54 Target // target-specific low-level ICE 56 Target // target-specific low-level ICE
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return new (Func->allocateInst<InstCall>()) 291 return new (Func->allocateInst<InstCall>())
290 InstCall(Func, NumArgs, Dest, CallTarget); 292 InstCall(Func, NumArgs, Dest, CallTarget);
291 } 293 }
292 void addArg(Operand *Arg) { addSource(Arg); } 294 void addArg(Operand *Arg) { addSource(Arg); }
293 Operand *getCallTarget() const { return getSrc(0); } 295 Operand *getCallTarget() const { return getSrc(0); }
294 Operand *getArg(SizeT I) const { return getSrc(I + 1); } 296 Operand *getArg(SizeT I) const { return getSrc(I + 1); }
295 SizeT getNumArgs() const { return getSrcSize() - 1; } 297 SizeT getNumArgs() const { return getSrcSize() - 1; }
296 virtual void dump(const Cfg *Func) const; 298 virtual void dump(const Cfg *Func) const;
297 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; } 299 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; }
298 300
299 private: 301 protected:
300 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget) 302 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget,
301 : Inst(Func, Inst::Call, NumArgs + 1, Dest) { 303 InstKind Kind=Inst::Call)
JF 2014/06/10 03:50:41 I think it's better to avoid default arguments in
jvoung (off chromium) 2014/06/12 05:48:30 Done.
304 : Inst(Func, Kind, NumArgs + 1, Dest) {
302 // Set HasSideEffects so that the call instruction can't be 305 // Set HasSideEffects so that the call instruction can't be
303 // dead-code eliminated. Don't set this for a deletable intrinsic 306 // dead-code eliminated. IntrinsicCalls can override this if the
304 // call. 307 // particular intrinsic is deletable and has no side-effects.
305 HasSideEffects = true; 308 HasSideEffects = true;
306 addSource(CallTarget); 309 addSource(CallTarget);
307 } 310 }
311 virtual ~InstCall() {}
312
313 private:
308 InstCall(const InstCall &) LLVM_DELETED_FUNCTION; 314 InstCall(const InstCall &) LLVM_DELETED_FUNCTION;
309 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION; 315 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION;
310 virtual ~InstCall() {}
311 }; 316 };
312 317
313 // Cast instruction (a.k.a. conversion operation). 318 // Cast instruction (a.k.a. conversion operation).
314 class InstCast : public Inst { 319 class InstCast : public Inst {
315 public: 320 public:
316 enum OpKind { 321 enum OpKind {
317 #define X(tag, str) tag, 322 #define X(tag, str) tag,
318 ICEINSTCAST_TABLE 323 ICEINSTCAST_TABLE
319 #undef X 324 #undef X
320 _num 325 _num
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 393
389 private: 394 private:
390 InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1, 395 InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1,
391 Operand *Source2); 396 Operand *Source2);
392 InstIcmp(const InstIcmp &) LLVM_DELETED_FUNCTION; 397 InstIcmp(const InstIcmp &) LLVM_DELETED_FUNCTION;
393 InstIcmp &operator=(const InstIcmp &) LLVM_DELETED_FUNCTION; 398 InstIcmp &operator=(const InstIcmp &) LLVM_DELETED_FUNCTION;
394 virtual ~InstIcmp() {} 399 virtual ~InstIcmp() {}
395 const ICond Condition; 400 const ICond Condition;
396 }; 401 };
397 402
403 // Call to an intrinsic funciton. The call target is captured as getSrc(0),
JF 2014/06/10 03:50:41 s/funciton/function/
jvoung (off chromium) 2014/06/12 05:48:30 Done.
404 // and arg I is captured as getSrc(I+1).
405 class InstIntrinsicCall : public InstCall {
406 public:
407 static InstIntrinsicCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest,
408 Operand *CallTarget,
409 const IntrinsicInfo &Info) {
410 return new (Func->allocateInst<InstIntrinsicCall>())
411 InstIntrinsicCall(Func, NumArgs, Dest, CallTarget, Info);
412 }
413 static bool classof(const Inst *Inst) {
414 return Inst->getKind() == IntrinsicCall;
415 }
416
417 IntrinsicInfo getIntrinsicInfo() const { return Info; }
418 private:
419 InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest,
420 Operand *CallTarget, const IntrinsicInfo &Info)
421 : InstCall(Func, NumArgs, Dest, CallTarget, Inst::IntrinsicCall),
422 Info(Info) {
423 HasSideEffects = Info.HasSideEffects;
Jim Stichnoth 2014/06/10 22:58:28 I think I'd be more comfortable if the InstCall ct
jvoung (off chromium) 2014/06/12 05:48:30 Done.
424 }
425 InstIntrinsicCall(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION;
426 InstIntrinsicCall &operator=(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION;
427 virtual ~InstIntrinsicCall() {}
428 const IntrinsicInfo Info;
429 };
430
398 // Load instruction. The source address is captured in getSrc(0). 431 // Load instruction. The source address is captured in getSrc(0).
399 class InstLoad : public Inst { 432 class InstLoad : public Inst {
400 public: 433 public:
401 static InstLoad *create(Cfg *Func, Variable *Dest, Operand *SourceAddr) { 434 static InstLoad *create(Cfg *Func, Variable *Dest, Operand *SourceAddr) {
402 return new (Func->allocateInst<InstLoad>()) 435 return new (Func->allocateInst<InstLoad>())
403 InstLoad(Func, Dest, SourceAddr); 436 InstLoad(Func, Dest, SourceAddr);
404 } 437 }
405 Operand *getSourceAddress() const { return getSrc(0); } 438 Operand *getSourceAddress() const { return getSrc(0); }
406 virtual void dump(const Cfg *Func) const; 439 virtual void dump(const Cfg *Func) const;
407 static bool classof(const Inst *Inst) { return Inst->getKind() == Load; } 440 static bool classof(const Inst *Inst) { return Inst->getKind() == Load; }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 assert(Kind >= Target); 699 assert(Kind >= Target);
667 } 700 }
668 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION; 701 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION;
669 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION; 702 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION;
670 virtual ~InstTarget() {} 703 virtual ~InstTarget() {}
671 }; 704 };
672 705
673 } // end of namespace Ice 706 } // end of namespace Ice
674 707
675 #endif // SUBZERO_SRC_ICEINST_H 708 #endif // SUBZERO_SRC_ICEINST_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698