Skip to content

And What is A Clang Exactly

November 12, 2014

I’m working on understanding the LLVM compiler by concentrating on an implementation for a “toy” architecture LEG which is a subset of ARM. I’m starting with looking hard at the file structure for the leg tutorial example code. I’ve done the core LLVM files and now I’m looking at the Clang compiler.

The Clang folder for LEG has only 6 files different from the base llvm-clang at release 3.4.2


Two of the files have substantial changes, the others are more like release date or id changes which may not matter. I can almost imagine I understand the bits and pieces. If I can figure the llvm stuff out this will be much easier.

-- C:\Users\bill\Downloads\LLVM\CFE-3.4.2.src : C:\Users\bill\Downloads\LLVM\Clang-leg-leg_for_release_34 
.\lib\basic\targets.cpp	different 
	adds lines around 5539 to describe LEGTargetInfo similar to others ahead of it
		namespace {
		class LEGTargetInfo : public TargetInfo {
		  LEGTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
		    BigEndian = false;
		    NoAsmVariants = true;
		    LongLongAlign = 32;
		    SuitableAlign = 32;
		    DoubleAlign = LongDoubleAlign = 32;
		    SizeType = UnsignedInt;
		    PtrDiffType = SignedInt;
		    IntPtrType = SignedInt;
		    WCharType = UnsignedChar;
		    WIntType = UnsignedInt;
		    UseZeroLengthBitfieldAlignment = true;
		    DescriptionString = "e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32"
		  void getTargetDefines(const LangOptions &Opts,
					MacroBuilder &Builder) const LLVM_OVERRIDE { }
		  void getTargetBuiltins(const Builtin::Info *&Records,
					 unsigned &NumRecords) const LLVM_OVERRIDE { }
		  BuiltinVaListKind getBuiltinVaListKind() const LLVM_OVERRIDE {
		    return TargetInfo::VoidPtrBuiltinVaList;
		  const char *getClobbers() const LLVM_OVERRIDE {
		    return "";
		  void getGCCRegNames(const char * const *&Names,
				      unsigned &NumNames) const LLVM_OVERRIDE {
		    Names = NULL;
		    NumNames = 0;
		  void getGCCRegAliases(const GCCRegAlias *&Aliases,
					unsigned &NumAliases) const LLVM_OVERRIDE {
		    Aliases = NULL;
		    NumAliases = 0;
		  bool validateAsmConstraint(const char *&Name,
					     TargetInfo::ConstraintInfo &Info) const LLVM_OVERRIDE {
		    return false;
		  int getEHDataRegisterNumber(unsigned RegNo) const LLVM_OVERRIDE {
		    // R0=ExceptionPointerRegister R1=ExceptionSelectorRegister
		    return -1;
	} // end anonymous namespace.
	adds lines 5600-5602 to put xx in the AllocateTarget function
	  case llvm::Triple::leg:
	    return new LEGTargetInfo(Triple);
	actually simplifies line 39 - probably ignorable
	adds lines 5504-5519 to describe the LEG ABI
		// LEG ABI Implementation
		namespace {
		class LEGABIInfo : public DefaultABIInfo {
		  LEGABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}

		class LEGTargetCodeGenInfo : public TargetCodeGenInfo {
		  LEGTargetCodeGenInfo(CodeGenTypes &CGT)
		      : TargetCodeGenInfo(new LEGABIInfo(CGT)) {}
		} // End anonymous namespace.
	and lines 5633-5634 add leg to the switch in the getTargetCodeGenInfo function
	  case llvm::Triple::leg:
	    return *(TheTargetCodeGenInfo = new LEGTargetCodeGenInfo(Types));

	looks like an ignorable change to line 3
	looks ignorable
	looks ignorable

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: