Computer Laboratory

Detailed Description

An annotation applied by LLVM to a pointer.

Definition at line 49 of file Annotations.h.

#include "Annotations.h"

+ Inheritance diagram for tesla::PtrAnnotation:
+ Collaboration diagram for tesla::PtrAnnotation:

Public Types

enum  AnnotationKind { AK_RawAnnotation, AK_FieldAnnotation }
 

Public Member Functions

virtual ~PtrAnnotation ()
 
virtual AnnotationKind getKind () const
 
llvm::StringRef getName () const
 
const llvm::Value * getValue () const
 

Static Public Member Functions

static bool classof (const PtrAnnotation *P)
 
static PtrAnnotationInterpret (llvm::User *)
 

Protected Member Functions

 PtrAnnotation (llvm::CallInst *Call, const llvm::Value *PtrArg, llvm::StringRef Name, llvm::StringRef Filename, llvm::APInt &Line)
 

Static Protected Member Functions

static llvm::StringRef ExtractStringConstant (const llvm::Value *V)
 

Protected Attributes

llvm::CallInst * Call
 
const llvm::Value * PtrArg
 
const llvm::StringRef Name
 
const llvm::StringRef Filename
 
const llvm::APInt & Line
 

Member Enumeration Documentation

Enumerator
AK_RawAnnotation 
AK_FieldAnnotation 

Definition at line 53 of file Annotations.h.

Constructor & Destructor Documentation

virtual tesla::PtrAnnotation::~PtrAnnotation ( )
inlinevirtual

Definition at line 51 of file Annotations.h.

51 {}
tesla::PtrAnnotation::PtrAnnotation ( llvm::CallInst *  Call,
const llvm::Value *  PtrArg,
llvm::StringRef  Name,
llvm::StringRef  Filename,
llvm::APInt &  Line 
)
inlineprotected

Definition at line 62 of file Annotations.h.

66  {
67  }

Member Function Documentation

static bool tesla::PtrAnnotation::classof ( const PtrAnnotation P)
inlinestatic

Definition at line 55 of file Annotations.h.

55 { return true; }
StringRef tesla::PtrAnnotation::ExtractStringConstant ( const llvm::Value *  V)
staticprotected

Definition at line 66 of file Annotations.cpp.

66  {
67  auto *Ptr = dyn_cast<ConstantExpr>(V);
68  assert(Ptr && Ptr->isGEPWithNoNotionalOverIndexing());
69 
70  auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0));
71  auto *Array = dyn_cast<ConstantDataArray>(Var->getInitializer());
72 
73  return Array->getAsString();
74 }
virtual AnnotationKind tesla::PtrAnnotation::getKind ( ) const
inlinevirtual

Reimplemented in tesla::FieldAnnotation.

Definition at line 54 of file Annotations.h.

References AK_RawAnnotation.

Referenced by tesla::FieldAnnotation::classof().

54 { return AK_RawAnnotation; }

+ Here is the caller graph for this function:

llvm::StringRef tesla::PtrAnnotation::getName ( ) const
inline

Definition at line 58 of file Annotations.h.

References Name.

58 { return Name; }
const llvm::Value* tesla::PtrAnnotation::getValue ( ) const
inline

Definition at line 59 of file Annotations.h.

References Call.

59 { return Call; }
PtrAnnotation * tesla::PtrAnnotation::Interpret ( llvm::User *  )
static

Definition at line 42 of file Annotations.cpp.

42  {
43  assert(U);
44 
45  auto *Call = dyn_cast<CallInst>(U);
46  assert(Call);
47  assert(Call->getNumArgOperands() == 4);
48 
49  Value *Ptr(Call->getArgOperand(0));
50  StringRef Name(ExtractStringConstant(Call->getArgOperand(1)));
51  StringRef Filename(ExtractStringConstant(Call->getArgOperand(2)));
52  APInt Line = dyn_cast<ConstantInt>(Call->getArgOperand(3))->getValue();
53 
54  const string FIELD = "field:";
55 
56  if (!Name.startswith(FIELD))
57  return new PtrAnnotation(Call, Ptr, Name, Filename, Line);
58 
59  size_t Dot(Name.find('.'));
60  StringRef StructName(Name.slice(FIELD.length(), Dot));
61  StringRef FieldName(Name.substr(Dot + 1));
62 
63  return new FieldAnnotation(Call, Ptr, StructName, FieldName, Filename, Line);
64 }

Member Data Documentation

llvm::CallInst* tesla::PtrAnnotation::Call
protected
const llvm::StringRef tesla::PtrAnnotation::Filename
protected

Definition at line 74 of file Annotations.h.

const llvm::APInt& tesla::PtrAnnotation::Line
protected

Definition at line 75 of file Annotations.h.

const llvm::StringRef tesla::PtrAnnotation::Name
protected

Definition at line 73 of file Annotations.h.

Referenced by getName().

const llvm::Value* tesla::PtrAnnotation::PtrArg
protected

Definition at line 72 of file Annotations.h.


The documentation for this class was generated from the following files: