Purple  0.1
Standard Language Specification
Functions
clang.c File Reference

Functions for interacting with clang. More...

#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "data.h"
#include "utils/clang.h"
#include "utils/logging.h"
Include dependency graph for clang.c:

Functions

const char * get_temp_dir (void)
 Get the default temporary directory. More...
 
void create_tmp_generator_program (void)
 Create a temporary file for a generator program used to determine compilation information. 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 clang_compile_llvm (const char *fn)
 Starts up the clang compiler to compile the generated LLVM-IR into a binary. 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 * regex_match (const char *regex, char *target_str, int len, int group_index)
 Simple regex parser. More...
 

Detailed Description

Functions for interacting with clang.

Author
Charles Averill
Date
13-Sep-2022

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_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

◆ get_temp_dir()

const char * get_temp_dir ( void  )

Get the default temporary directory.

Returns
const char* String containing temporary directory name

◆ 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