clang API Documentation

Defines | Enumerations | Functions
CGStmt.cpp File Reference
#include "CodeGenFunction.h"
#include "CGDebugInfo.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/PrettyStackTrace.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/LoopHint.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Intrinsics.h"
#include "clang/AST/StmtNodes.inc"
Include dependency graph for CGStmt.cpp:

Go to the source code of this file.

Defines

#define STMT(Type, Base)
#define ABSTRACT_STMT(Op)
#define EXPR(Type, Base)   case Stmt::Type##Class:

Enumerations

enum  CSFC_Result { CSFC_Failure, CSFC_FallThrough, CSFC_Success }

Functions

static CSFC_Result CollectStatementsForCase (const Stmt *S, const SwitchCase *Case, bool &FoundCase, SmallVectorImpl< const Stmt * > &ResultStmts)
static bool FindCaseStatementsForValue (const SwitchStmt &S, const llvm::APSInt &ConstantCondValue, SmallVectorImpl< const Stmt * > &ResultStmts, ASTContext &C, const SwitchCase *&ResultCase)
static std::string SimplifyConstraint (const char *Constraint, const TargetInfo &Target, SmallVectorImpl< TargetInfo::ConstraintInfo > *OutCons=nullptr)
static std::string AddVariableConstraints (const std::string &Constraint, const Expr &AsmExpr, const TargetInfo &Target, CodeGenModule &CGM, const AsmStmt &Stmt)
static llvm::MDNode * getAsmSrcLocInfo (const StringLiteral *Str, CodeGenFunction &CGF)

Define Documentation

#define ABSTRACT_STMT (   Op)
#define EXPR (   Type,
  Base 
)    case Stmt::Type##Class:
#define STMT (   Type,
  Base 
)

Enumeration Type Documentation

CollectStatementsForCase - Given the body of a 'switch' statement and a constant value that is being switched on, see if we can dead code eliminate the body of the switch to a simple series of statements to emit. Basically, on a switch (5) we want to find these statements: case 5: printf(...); <-- ++i; <-- break;

and add them to the ResultStmts vector. If it is unsafe to do this transformation (for example, one of the elided statements contains a label that might be jumped to), return CSFC_Failure. If we handled it and 'S' should include statements after it (e.g. the printf() line is a substmt of the case) then return CSFC_FallThrough. If we handled it and found a break statement, then return CSFC_Success.

If Case is non-null, then we are looking for the specified case, checking that nothing we jump over contains labels. If Case is null, then we found the case and are looking for the break.

If the recursive walk actually finds our Case, then we set FoundCase to true.

Enumerator:
CSFC_Failure 
CSFC_FallThrough 
CSFC_Success 

Definition at line 1326 of file CGStmt.cpp.


Function Documentation

static std::string AddVariableConstraints ( const std::string &  Constraint,
const Expr AsmExpr,
const TargetInfo Target,
CodeGenModule CGM,
const AsmStmt Stmt 
) [static]

AddVariableConstraints - Look at AsmExpr and if it is a variable declared as using a particular register add that as a constraint that will be used in this asm stmt.

Definition at line 1688 of file CGStmt.cpp.

References clang::CodeGen::CodeGenModule::ErrorUnsupported(), clang::Decl::getAttr(), clang::DeclRefExpr::getDecl(), clang::TargetInfo::getNormalizedGCCRegisterName(), clang::VarDecl::getStorageClass(), clang::TargetInfo::isValidGCCRegisterName(), clang::SC_Register, and clang::TargetInfo::validateOutputConstraint().

Referenced by clang::CodeGen::CodeGenFunction::EmitAsmStmt().

static CSFC_Result CollectStatementsForCase ( const Stmt S,
const SwitchCase Case,
bool FoundCase,
SmallVectorImpl< const Stmt * > &  ResultStmts 
) [static]
static bool FindCaseStatementsForValue ( const SwitchStmt S,
const llvm::APSInt &  ConstantCondValue,
SmallVectorImpl< const Stmt * > &  ResultStmts,
ASTContext C,
const SwitchCase *&  ResultCase 
) [static]

FindCaseStatementsForValue - Find the case statement being jumped to and then invoke CollectStatementsForCase to find the list of statements to emit for a switch on constant. See the comment above CollectStatementsForCase for more details.

Definition at line 1453 of file CGStmt.cpp.

References CollectStatementsForCase(), clang::CodeGen::CodeGenFunction::ContainsLabel(), CSFC_Failure, clang::Expr::EvaluateKnownConstInt(), clang::SwitchStmt::getBody(), clang::CaseStmt::getLHS(), clang::SwitchCase::getNextSwitchCase(), clang::CaseStmt::getRHS(), and clang::SwitchStmt::getSwitchCaseList().

Referenced by clang::CodeGen::CodeGenFunction::EmitSwitchStmt().

static llvm::MDNode* getAsmSrcLocInfo ( const StringLiteral Str,
CodeGenFunction CGF 
) [static]
static std::string SimplifyConstraint ( const char *  Constraint,
const TargetInfo Target,
SmallVectorImpl< TargetInfo::ConstraintInfo > *  OutCons = nullptr 
) [static]