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

Side by Side Diff: src/IceTargetLowering.h

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 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
« no previous file with comments | « src/IceSwitchLowering.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// 1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- 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 /// \file 10 /// \file
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // a TargetLowering object pointer and an Inst pointer, it adds appropriate 50 // a TargetLowering object pointer and an Inst pointer, it adds appropriate
51 // FakeDef and FakeUse instructions to try maintain liveness consistency. 51 // FakeDef and FakeUse instructions to try maintain liveness consistency.
52 #define UnimplementedLoweringError(Target, Instr) \ 52 #define UnimplementedLoweringError(Target, Instr) \
53 do { \ 53 do { \
54 if ((Target)->Ctx->getFlags().getSkipUnimplemented()) { \ 54 if ((Target)->Ctx->getFlags().getSkipUnimplemented()) { \
55 (Target)->addFakeDefUses(Instr); \ 55 (Target)->addFakeDefUses(Instr); \
56 } else { \ 56 } else { \
57 /* Use llvm_unreachable instead of report_fatal_error, which gives \ 57 /* Use llvm_unreachable instead of report_fatal_error, which gives \
58 better stack traces. */ \ 58 better stack traces. */ \
59 llvm_unreachable( \ 59 llvm_unreachable( \
60 ("Not yet implemented: " + Instr->getInstName()).c_str()); \ 60 (std::string("Not yet implemented: ") + Instr->getInstName()) \
61 .c_str()); \
61 abort(); \ 62 abort(); \
62 } \ 63 } \
63 } while (0) 64 } while (0)
64 65
65 /// LoweringContext makes it easy to iterate through non-deleted instructions in 66 /// LoweringContext makes it easy to iterate through non-deleted instructions in
66 /// a node, and insert new (lowered) instructions at the current point. Along 67 /// a node, and insert new (lowered) instructions at the current point. Along
67 /// with the instruction list container and associated iterators, it holds the 68 /// with the instruction list container and associated iterators, it holds the
68 /// current node, which is needed when inserting new instructions in order to 69 /// current node, which is needed when inserting new instructions in order to
69 /// track whether variables are used as single-block or multi-block. 70 /// track whether variables are used as single-block or multi-block.
70 class LoweringContext { 71 class LoweringContext {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 /// } 166 /// }
166 class TargetLowering { 167 class TargetLowering {
167 TargetLowering() = delete; 168 TargetLowering() = delete;
168 TargetLowering(const TargetLowering &) = delete; 169 TargetLowering(const TargetLowering &) = delete;
169 TargetLowering &operator=(const TargetLowering &) = delete; 170 TargetLowering &operator=(const TargetLowering &) = delete;
170 171
171 public: 172 public:
172 static void staticInit(GlobalContext *Ctx); 173 static void staticInit(GlobalContext *Ctx);
173 // Each target must define a public static method: 174 // Each target must define a public static method:
174 // static void staticInit(GlobalContext *Ctx); 175 // static void staticInit(GlobalContext *Ctx);
176 static bool shouldBePooled(const class Constant *C);
175 177
176 static std::unique_ptr<TargetLowering> createLowering(TargetArch Target, 178 static std::unique_ptr<TargetLowering> createLowering(TargetArch Target,
177 Cfg *Func); 179 Cfg *Func);
178 180
179 virtual std::unique_ptr<Assembler> createAssembler() const = 0; 181 virtual std::unique_ptr<Assembler> createAssembler() const = 0;
180 182
181 void translate() { 183 void translate() {
182 switch (Ctx->getFlags().getOptLevel()) { 184 switch (Ctx->getFlags().getOptLevel()) {
183 case Opt_m1: 185 case Opt_m1:
184 translateOm1(); 186 translateOm1();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 232 }
231 233
232 virtual SizeT getNumRegisters() const = 0; 234 virtual SizeT getNumRegisters() const = 0;
233 /// Returns a variable pre-colored to the specified physical register. This is 235 /// Returns a variable pre-colored to the specified physical register. This is
234 /// generally used to get very direct access to the register such as in the 236 /// generally used to get very direct access to the register such as in the
235 /// prolog or epilog or for marking scratch registers as killed by a call. If 237 /// prolog or epilog or for marking scratch registers as killed by a call. If
236 /// a Type is not provided, a target-specific default type is used. 238 /// a Type is not provided, a target-specific default type is used.
237 virtual Variable *getPhysicalRegister(RegNumT RegNum, 239 virtual Variable *getPhysicalRegister(RegNumT RegNum,
238 Type Ty = IceType_void) = 0; 240 Type Ty = IceType_void) = 0;
239 /// Returns a printable name for the register. 241 /// Returns a printable name for the register.
240 virtual IceString getRegName(RegNumT RegNum, Type Ty) const = 0; 242 virtual const char *getRegName(RegNumT RegNum, Type Ty) const = 0;
241 243
242 virtual bool hasFramePointer() const { return false; } 244 virtual bool hasFramePointer() const { return false; }
243 virtual void setHasFramePointer() = 0; 245 virtual void setHasFramePointer() = 0;
244 virtual RegNumT getStackReg() const = 0; 246 virtual RegNumT getStackReg() const = 0;
245 virtual RegNumT getFrameReg() const = 0; 247 virtual RegNumT getFrameReg() const = 0;
246 virtual RegNumT getFrameOrStackReg() const = 0; 248 virtual RegNumT getFrameOrStackReg() const = 0;
247 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; 249 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0;
248 virtual uint32_t getStackAlignment() const = 0; 250 virtual uint32_t getStackAlignment() const = 0;
249 virtual void reserveFixedAllocaArea(size_t Size, size_t Align) = 0; 251 virtual void reserveFixedAllocaArea(size_t Size, size_t Align) = 0;
250 virtual int32_t getFrameFixedAllocaOffset() const = 0; 252 virtual int32_t getFrameFixedAllocaOffset() const = 0;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 InstBundleLock::Opt_None); 359 InstBundleLock::Opt_None);
358 ~AutoBundle(); 360 ~AutoBundle();
359 361
360 private: 362 private:
361 TargetLowering *const Target; 363 TargetLowering *const Target;
362 const bool NeedSandboxing; 364 const bool NeedSandboxing;
363 }; 365 };
364 366
365 explicit TargetLowering(Cfg *Func); 367 explicit TargetLowering(Cfg *Func);
366 // Applies command line filters to TypeToRegisterSet array. 368 // Applies command line filters to TypeToRegisterSet array.
367 static void 369 static void filterTypeToRegisterSet(
368 filterTypeToRegisterSet(GlobalContext *Ctx, int32_t NumRegs, 370 GlobalContext *Ctx, int32_t NumRegs, SmallBitVector TypeToRegisterSet[],
369 SmallBitVector TypeToRegisterSet[], 371 size_t TypeToRegisterSetSize,
370 size_t TypeToRegisterSetSize, 372 std::function<std::string(RegNumT)> getRegName,
371 std::function<IceString(RegNumT)> getRegName, 373 std::function<const char *(RegClass)> getRegClassName);
372 std::function<IceString(RegClass)> getRegClassName);
373 virtual void lowerAlloca(const InstAlloca *Instr) = 0; 374 virtual void lowerAlloca(const InstAlloca *Instr) = 0;
374 virtual void lowerArithmetic(const InstArithmetic *Instr) = 0; 375 virtual void lowerArithmetic(const InstArithmetic *Instr) = 0;
375 virtual void lowerAssign(const InstAssign *Instr) = 0; 376 virtual void lowerAssign(const InstAssign *Instr) = 0;
376 virtual void lowerBr(const InstBr *Instr) = 0; 377 virtual void lowerBr(const InstBr *Instr) = 0;
377 virtual void lowerCall(const InstCall *Instr) = 0; 378 virtual void lowerCall(const InstCall *Instr) = 0;
378 virtual void lowerCast(const InstCast *Instr) = 0; 379 virtual void lowerCast(const InstCast *Instr) = 0;
379 virtual void lowerFcmp(const InstFcmp *Instr) = 0; 380 virtual void lowerFcmp(const InstFcmp *Instr) = 0;
380 virtual void lowerExtractElement(const InstExtractElement *Instr) = 0; 381 virtual void lowerExtractElement(const InstExtractElement *Instr) = 0;
381 virtual void lowerIcmp(const InstIcmp *Instr) = 0; 382 virtual void lowerIcmp(const InstIcmp *Instr) = 0;
382 virtual void lowerInsertElement(const InstInsertElement *Instr) = 0; 383 virtual void lowerInsertElement(const InstInsertElement *Instr) = 0;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 class TargetDataLowering { 577 class TargetDataLowering {
577 TargetDataLowering() = delete; 578 TargetDataLowering() = delete;
578 TargetDataLowering(const TargetDataLowering &) = delete; 579 TargetDataLowering(const TargetDataLowering &) = delete;
579 TargetDataLowering &operator=(const TargetDataLowering &) = delete; 580 TargetDataLowering &operator=(const TargetDataLowering &) = delete;
580 581
581 public: 582 public:
582 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); 583 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx);
583 virtual ~TargetDataLowering(); 584 virtual ~TargetDataLowering();
584 585
585 virtual void lowerGlobals(const VariableDeclarationList &Vars, 586 virtual void lowerGlobals(const VariableDeclarationList &Vars,
586 const IceString &SectionSuffix) = 0; 587 const std::string &SectionSuffix) = 0;
587 virtual void lowerConstants() = 0; 588 virtual void lowerConstants() = 0;
588 virtual void lowerJumpTables() = 0; 589 virtual void lowerJumpTables() = 0;
589 590
590 protected: 591 protected:
591 void emitGlobal(const VariableDeclaration &Var, 592 void emitGlobal(const VariableDeclaration &Var,
592 const IceString &SectionSuffix); 593 const std::string &SectionSuffix);
593 594
594 /// For now, we assume .long is the right directive for emitting 4 byte emit 595 /// For now, we assume .long is the right directive for emitting 4 byte emit
595 /// global relocations. However, LLVM MIPS usually uses .4byte instead. 596 /// global relocations. However, LLVM MIPS usually uses .4byte instead.
596 /// Perhaps there is some difference when the location is unaligned. 597 /// Perhaps there is some difference when the location is unaligned.
597 static const char *getEmit32Directive() { return ".long"; } 598 static const char *getEmit32Directive() { return ".long"; }
598 599
599 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 600 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
600 GlobalContext *Ctx; 601 GlobalContext *Ctx;
601 }; 602 };
602 603
(...skipping 13 matching lines...) Expand all
616 virtual void lower() {} 617 virtual void lower() {}
617 618
618 protected: 619 protected:
619 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 620 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
620 GlobalContext *Ctx; 621 GlobalContext *Ctx;
621 }; 622 };
622 623
623 } // end of namespace Ice 624 } // end of namespace Ice
624 625
625 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 626 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW
« no previous file with comments | « src/IceSwitchLowering.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698