Purple  0.1
Standard Language Specification
Macros | Functions | Variables
clang.h File Reference

Function headers for interacting with clang. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GENERATOR_PROGRAM_CONTENTS   "#include <stdio.h>\nint main(void){printf(\"\");}"
 Program used to determine platform information. More...
 
#define GENERATOR_PROGRAM_CONTENTS_LENGTH   sizeof(GENERATOR_PROGRAM_CONTENTS)
 Length of GENERATOR_PROGRAM_CONTENTS. More...
 
#define GENERATOR_PROGRAM_FILENAME   ".prp_platform_information_generator.c"
 Filename of GENERATOR_PROGRAM. More...
 
#define GENERATOR_PROGRAM_FILENAME_LL   ".prp_platform_information_generator.ll"
 Filename of GENERATOR_PROGRAM's LLVM-compiled file. More...
 
#define PURPLE_GLOBALS_PLACEHOLDER   ";<purple_globals_placeholder>"
 Placeholder in main LLVM file used when linking globals. More...
 
#define PURPLE_GLOBALS_PLACEHOLDER_LEN   sizeof(PURPLE_GLOBALS_PLACEHOLDER) - 1
 Length of PURPLE_GLOBALS_PLACEHOLDER. More...
 

Functions

void clang_compile_llvm (const char *fn)
 Starts up the clang compiler to compile the generated LLVM-IR into a binary. More...
 
void link_globals (void)
 Link globals.ll to main LLVM file by copying the contents of each LLVM file into a temporary file, then copying back to the main LLVM file. More...
 
void create_tmp_generator_program (void)
 Create a temporary file for a generator program used to determine compilation information. More...
 
char * get_target_datalayout (void)
 Search through GENERATOR_PROGRAM for the target datalayout. More...
 
char * get_target_triple (void)
 Get the target triple for the current target. More...
 
char * get_postamble (void)
 
char * regex_match (const char *regex, char *target_str, int len, int group_index)
 Simple regex parser. More...
 

Variables

static char generatorProgramFullPath [512]
 Full path to GENERATOR_PROGRAM. More...
 
static char generatorProgramLLFullPath [512]
 Full path to GENERATOR_PROGRAM's LLVM-compiled file. More...
 
static bool generatorProgramWritten = false
 True if the generator program has been written and compiled. More...
 

Detailed Description

Function headers for interacting with clang.

Author
Charles Averill
Date
13-Sep-2022

Macro Definition Documentation

◆ GENERATOR_PROGRAM_CONTENTS

#define GENERATOR_PROGRAM_CONTENTS   "#include <stdio.h>\nint main(void){printf(\"\");}"

Program used to determine platform information.

◆ GENERATOR_PROGRAM_CONTENTS_LENGTH

#define GENERATOR_PROGRAM_CONTENTS_LENGTH   sizeof(GENERATOR_PROGRAM_CONTENTS)

Length of GENERATOR_PROGRAM_CONTENTS.

◆ GENERATOR_PROGRAM_FILENAME

#define GENERATOR_PROGRAM_FILENAME   ".prp_platform_information_generator.c"

Filename of GENERATOR_PROGRAM.

◆ GENERATOR_PROGRAM_FILENAME_LL

#define GENERATOR_PROGRAM_FILENAME_LL   ".prp_platform_information_generator.ll"

Filename of GENERATOR_PROGRAM's LLVM-compiled file.

◆ PURPLE_GLOBALS_PLACEHOLDER

#define PURPLE_GLOBALS_PLACEHOLDER   ";<purple_globals_placeholder>"

Placeholder in main LLVM file used when linking globals.

◆ PURPLE_GLOBALS_PLACEHOLDER_LEN

#define PURPLE_GLOBALS_PLACEHOLDER_LEN   sizeof(PURPLE_GLOBALS_PLACEHOLDER) - 1

Length of PURPLE_GLOBALS_PLACEHOLDER.

Function Documentation

◆ clang_compile_llvm()

void clang_compile_llvm ( const char *  fn)

Starts up the clang compiler to compile the generated LLVM-IR into a binary.

Parameters
fnName of file to compile

◆ create_tmp_generator_program()

void create_tmp_generator_program ( void  )

Create a temporary file for a generator program used to determine compilation information.

◆ get_postamble()

char * get_postamble ( void  )

◆ get_target_datalayout()

char * get_target_datalayout ( void  )

Search through GENERATOR_PROGRAM for the target datalayout.

Returns
char* Pointer to target datalayout string

◆ get_target_triple()

char * get_target_triple ( void  )

Get the target triple for the current target.

Returns
char* Pointer to the target triple string

◆ link_globals()

void link_globals ( void  )

Link globals.ll to main LLVM file by copying the contents of each LLVM file into a temporary file, then copying back to the main LLVM file.

◆ regex_match()

char * regex_match ( const char *  regex,
char *  target_str,
int  len,
int  group_index 
)

Simple regex parser.

Parameters
regexRegular expression to compile
target_strString to search in
lenMaximum length of the output match, if found
group_indexIndex of group to match (0 for no group)
Returns
char* Pointer to the match text if match found, else NULL

Variable Documentation

◆ generatorProgramFullPath

char generatorProgramFullPath[512]
static

Full path to GENERATOR_PROGRAM.

◆ generatorProgramLLFullPath

char generatorProgramLLFullPath[512]
static

Full path to GENERATOR_PROGRAM's LLVM-compiled file.

◆ generatorProgramWritten

bool generatorProgramWritten = false
static

True if the generator program has been written and compiled.