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

Side by Side Diff: src/IceTargetLowering.h

Issue 1585843007: Subzero. RAII NaCl Bundling. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 /// Performs target-specific argument lowering. 291 /// Performs target-specific argument lowering.
292 virtual void lowerArguments() = 0; 292 virtual void lowerArguments() = 0;
293 293
294 virtual void initNodeForLowering(CfgNode *) {} 294 virtual void initNodeForLowering(CfgNode *) {}
295 virtual void addProlog(CfgNode *Node) = 0; 295 virtual void addProlog(CfgNode *Node) = 0;
296 virtual void addEpilog(CfgNode *Node) = 0; 296 virtual void addEpilog(CfgNode *Node) = 0;
297 297
298 virtual ~TargetLowering() = default; 298 virtual ~TargetLowering() = default;
299 299
300 private:
301 // This control variable is used by AutoBundle (RAII-style bundle
302 // locking/unlocking) to prevent nested bundles.
303 bool AutoBundling = false;
304
305 // _bundle_lock(), and _bundle_unlock(), were made private to force subtargets
306 // to use the AutoBundle helper.
307 void
308 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
309 Context.insert<InstBundleLock>(BundleOption);
310 }
311 void _bundle_unlock() { Context.insert<InstBundleUnlock>(); }
312
300 protected: 313 protected:
314 /// AutoBundle provides RIAA-style bundling. Sub-targets are expected to use
315 /// it when emitting NaCl Bundles to ensure proper bundle_unlocking, and
316 /// prevent nested bundles.
317 ///
318 /// AutoBundle objects will emit a _bundle_lock during construction (but only
319 /// if sandboxed code generation was requested), and a bundle_unlock() during
320 /// destruction. By carefully scoping objects of this type, Subtargets can
321 /// ensure proper bundle emission.
322 class AutoBundle {
323 AutoBundle() = delete;
324 AutoBundle(const AutoBundle &) = delete;
325 AutoBundle &operator=(const AutoBundle &) = delete;
326
327 public:
328 explicit AutoBundle(TargetLowering *Target, InstBundleLock::Option Option =
329 InstBundleLock::Opt_None);
330 ~AutoBundle();
331
332 private:
333 TargetLowering *const Target;
334 const bool NeedSandboxing;
335 };
336
301 explicit TargetLowering(Cfg *Func); 337 explicit TargetLowering(Cfg *Func);
302 virtual void lowerAlloca(const InstAlloca *Inst) = 0; 338 virtual void lowerAlloca(const InstAlloca *Inst) = 0;
303 virtual void lowerArithmetic(const InstArithmetic *Inst) = 0; 339 virtual void lowerArithmetic(const InstArithmetic *Inst) = 0;
304 virtual void lowerAssign(const InstAssign *Inst) = 0; 340 virtual void lowerAssign(const InstAssign *Inst) = 0;
305 virtual void lowerBr(const InstBr *Inst) = 0; 341 virtual void lowerBr(const InstBr *Inst) = 0;
306 virtual void lowerCall(const InstCall *Inst) = 0; 342 virtual void lowerCall(const InstCall *Inst) = 0;
307 virtual void lowerCast(const InstCast *Inst) = 0; 343 virtual void lowerCast(const InstCast *Inst) = 0;
308 virtual void lowerFcmp(const InstFcmp *Inst) = 0; 344 virtual void lowerFcmp(const InstFcmp *Inst) = 0;
309 virtual void lowerExtractElement(const InstExtractElement *Inst) = 0; 345 virtual void lowerExtractElement(const InstExtractElement *Inst) = 0;
310 virtual void lowerIcmp(const InstIcmp *Inst) = 0; 346 virtual void lowerIcmp(const InstIcmp *Inst) = 0;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 bool UsesFramePointer); 417 bool UsesFramePointer);
382 418
383 /// Sort the variables in Source based on required alignment. The variables 419 /// Sort the variables in Source based on required alignment. The variables
384 /// with the largest alignment need are placed in the front of the Dest list. 420 /// with the largest alignment need are placed in the front of the Dest list.
385 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; 421 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const;
386 422
387 /// Make a call to an external helper function. 423 /// Make a call to an external helper function.
388 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, 424 InstCall *makeHelperCall(const IceString &Name, Variable *Dest,
389 SizeT MaxSrcs); 425 SizeT MaxSrcs);
390 426
391 void
392 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
393 Context.insert<InstBundleLock>(BundleOption);
394 }
395 void _bundle_unlock() { Context.insert<InstBundleUnlock>(); }
396 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); } 427 void _set_dest_redefined() { Context.getLastInserted()->setDestRedefined(); }
397 428
398 bool shouldOptimizeMemIntrins(); 429 bool shouldOptimizeMemIntrins();
399 430
400 Cfg *Func; 431 Cfg *Func;
401 GlobalContext *Ctx; 432 GlobalContext *Ctx;
402 bool HasComputedFrame = false; 433 bool HasComputedFrame = false;
403 bool CallsReturnsTwice = false; 434 bool CallsReturnsTwice = false;
404 SizeT NextLabelNumber = 0; 435 SizeT NextLabelNumber = 0;
405 SizeT NextJumpTableNumber = 0; 436 SizeT NextJumpTableNumber = 0;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 virtual void lower() {} 522 virtual void lower() {}
492 523
493 protected: 524 protected:
494 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 525 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
495 GlobalContext *Ctx; 526 GlobalContext *Ctx;
496 }; 527 };
497 528
498 } // end of namespace Ice 529 } // end of namespace Ice
499 530
500 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 531 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW
« no previous file with comments | « no previous file | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698