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

Side by Side Diff: src/IceTargetLowering.h

Issue 1472623002: Unify alloca, outgoing arg, and prolog construction (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review fixes. Also removed StackAdjustment. Created 5 years 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/IceInstX86BaseImpl.h ('k') | src/IceTargetLoweringARM32.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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 virtual uint32_t maxOutArgsSizeBytes() const { return 0; } 214 virtual uint32_t maxOutArgsSizeBytes() const { return 0; }
215 215
216 /// Return whether a 64-bit Variable should be split into a Variable64On32. 216 /// Return whether a 64-bit Variable should be split into a Variable64On32.
217 virtual bool shouldSplitToVariable64On32(Type Ty) const = 0; 217 virtual bool shouldSplitToVariable64On32(Type Ty) const = 0;
218 218
219 bool hasComputedFrame() const { return HasComputedFrame; } 219 bool hasComputedFrame() const { return HasComputedFrame; }
220 /// Returns true if this function calls a function that has the "returns 220 /// Returns true if this function calls a function that has the "returns
221 /// twice" attribute. 221 /// twice" attribute.
222 bool callsReturnsTwice() const { return CallsReturnsTwice; } 222 bool callsReturnsTwice() const { return CallsReturnsTwice; }
223 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } 223 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; }
224 int32_t getStackAdjustment() const { return StackAdjustment; }
225 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; }
226 void resetStackAdjustment() { StackAdjustment = 0; }
227 SizeT makeNextLabelNumber() { return NextLabelNumber++; } 224 SizeT makeNextLabelNumber() { return NextLabelNumber++; }
228 SizeT makeNextJumpTableNumber() { return NextJumpTableNumber++; } 225 SizeT makeNextJumpTableNumber() { return NextJumpTableNumber++; }
229 LoweringContext &getContext() { return Context; } 226 LoweringContext &getContext() { return Context; }
230 227
231 enum RegSet { 228 enum RegSet {
232 RegSet_None = 0, 229 RegSet_None = 0,
233 RegSet_CallerSave = 1 << 0, 230 RegSet_CallerSave = 1 << 0,
234 RegSet_CalleeSave = 1 << 1, 231 RegSet_CalleeSave = 1 << 1,
235 RegSet_StackPointer = 1 << 2, 232 RegSet_StackPointer = 1 << 2,
236 RegSet_FramePointer = 1 << 3, 233 RegSet_FramePointer = 1 << 3,
237 RegSet_All = ~RegSet_None 234 RegSet_All = ~RegSet_None
238 }; 235 };
239 using RegSetMask = uint32_t; 236 using RegSetMask = uint32_t;
240 237
241 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, 238 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include,
242 RegSetMask Exclude) const = 0; 239 RegSetMask Exclude) const = 0;
243 virtual const llvm::SmallBitVector & 240 virtual const llvm::SmallBitVector &
244 getRegistersForVariable(const Variable *Var) const = 0; 241 getRegistersForVariable(const Variable *Var) const = 0;
245 virtual const llvm::SmallBitVector &getAliasesForRegister(SizeT) const = 0; 242 virtual const llvm::SmallBitVector &getAliasesForRegister(SizeT) const = 0;
246 243
247 void regAlloc(RegAllocKind Kind); 244 void regAlloc(RegAllocKind Kind);
248 245
249 virtual void 246 virtual void
250 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation, 247 makeRandomRegisterPermutation(llvm::SmallVectorImpl<int32_t> &Permutation,
251 const llvm::SmallBitVector &ExcludeRegisters, 248 const llvm::SmallBitVector &ExcludeRegisters,
252 uint64_t Salt) const = 0; 249 uint64_t Salt) const = 0;
253 250
254 /// Save/restore any mutable state for the situation where code emission needs
255 /// multiple passes, such as sandboxing or relaxation. Subclasses may provide
256 /// their own implementation, but should be sure to also call the parent
257 /// class's methods.
258 virtual void snapshotEmitState() {
259 SnapshotStackAdjustment = StackAdjustment;
260 }
261 virtual void rollbackEmitState() {
262 StackAdjustment = SnapshotStackAdjustment;
263 }
264
265 /// Get the minimum number of clusters required for a jump table to be 251 /// Get the minimum number of clusters required for a jump table to be
266 /// considered. 252 /// considered.
267 virtual SizeT getMinJumpTableSize() const = 0; 253 virtual SizeT getMinJumpTableSize() const = 0;
268 virtual void emitJumpTable(const Cfg *Func, 254 virtual void emitJumpTable(const Cfg *Func,
269 const InstJumpTable *JumpTable) const = 0; 255 const InstJumpTable *JumpTable) const = 0;
270 256
271 virtual void emitVariable(const Variable *Var) const = 0; 257 virtual void emitVariable(const Variable *Var) const = 0;
272 258
273 void emitWithoutPrefix(const ConstantRelocatable *CR) const; 259 void emitWithoutPrefix(const ConstantRelocatable *CR) const;
274 void emit(const ConstantRelocatable *CR) const; 260 void emit(const ConstantRelocatable *CR) const;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 372 }
387 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } 373 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); }
388 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } 374 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); }
389 375
390 bool shouldOptimizeMemIntrins(); 376 bool shouldOptimizeMemIntrins();
391 377
392 Cfg *Func; 378 Cfg *Func;
393 GlobalContext *Ctx; 379 GlobalContext *Ctx;
394 bool HasComputedFrame = false; 380 bool HasComputedFrame = false;
395 bool CallsReturnsTwice = false; 381 bool CallsReturnsTwice = false;
396 /// StackAdjustment keeps track of the current stack offset from its natural
397 /// location, e.g. as arguments are pushed for a function call or as
398 /// fixed-size alloca instructions are executed in the entry block.
399 int32_t StackAdjustment = 0;
400 SizeT NextLabelNumber = 0; 382 SizeT NextLabelNumber = 0;
401 SizeT NextJumpTableNumber = 0; 383 SizeT NextJumpTableNumber = 0;
402 LoweringContext Context; 384 LoweringContext Context;
403 385
404 // Runtime helper function names 386 // Runtime helper function names
405 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; 387 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16";
406 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; 388 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8";
407 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; 389 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1";
408 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; 390 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1";
409 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; 391 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2";
(...skipping 21 matching lines...) Expand all
431 const static constexpr char *H_srem_i64 = "__moddi3"; 413 const static constexpr char *H_srem_i64 = "__moddi3";
432 const static constexpr char *H_udiv_i32 = "__udivsi3"; 414 const static constexpr char *H_udiv_i32 = "__udivsi3";
433 const static constexpr char *H_udiv_i64 = "__udivdi3"; 415 const static constexpr char *H_udiv_i64 = "__udivdi3";
434 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32"; 416 const static constexpr char *H_uitofp_4xi32_4xf32 = "__Sz_uitofp_4xi32_4xf32";
435 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; 417 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32";
436 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64"; 418 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64";
437 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32"; 419 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32";
438 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64"; 420 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64";
439 const static constexpr char *H_urem_i32 = "__umodsi3"; 421 const static constexpr char *H_urem_i32 = "__umodsi3";
440 const static constexpr char *H_urem_i64 = "__umoddi3"; 422 const static constexpr char *H_urem_i64 = "__umoddi3";
441
442 private:
443 int32_t SnapshotStackAdjustment = 0;
444 }; 423 };
445 424
446 /// TargetDataLowering is used for "lowering" data including initializers for 425 /// TargetDataLowering is used for "lowering" data including initializers for
447 /// global variables, and the internal constant pools. It is separated out from 426 /// global variables, and the internal constant pools. It is separated out from
448 /// TargetLowering because it does not require a Cfg. 427 /// TargetLowering because it does not require a Cfg.
449 class TargetDataLowering { 428 class TargetDataLowering {
450 TargetDataLowering() = delete; 429 TargetDataLowering() = delete;
451 TargetDataLowering(const TargetDataLowering &) = delete; 430 TargetDataLowering(const TargetDataLowering &) = delete;
452 TargetDataLowering &operator=(const TargetDataLowering &) = delete; 431 TargetDataLowering &operator=(const TargetDataLowering &) = delete;
453 432
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 virtual void lower() {} 468 virtual void lower() {}
490 469
491 protected: 470 protected:
492 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 471 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
493 GlobalContext *Ctx; 472 GlobalContext *Ctx;
494 }; 473 };
495 474
496 } // end of namespace Ice 475 } // end of namespace Ice
497 476
498 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 477 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW
« no previous file with comments | « src/IceInstX86BaseImpl.h ('k') | src/IceTargetLoweringARM32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698