Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
ir_bread.cxx File Reference
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <elf.h>
#include <sys/elf_whirl.h>
#include <errno.h>
#include "defs.h"
#include "alignof.h"
#include "erglob.h"
#include "errors.h"
#include "opcode.h"
#include "mempool.h"
#include "strtab.h"
#include "symtab.h"
#include "const.h"
#include "targ_const.h"
#include "config_targ.h"
#include "config_debug.h"
#include "config_elf_targ.h"
#include "irbdata.h"
#include "wn_core.h"
#include "wn.h"
#include "wn_map.h"
#include "dwarf_DST_mem.h"
#include "pu_info.h"
#include "ir_elf.h"
#include "ir_bwrite.h"
#include "ir_bcom.h"
#include "ir_bread.h"
#include "xstats.h"
#include "pf_cg.h"
Include dependency graph for ir_bread.cxx:

Go to the source code of this file.

Defines

#define USE_STANDARD_TYPES   /* override unwanted defines in "defs.h" */
#define USE_DST_INTERNALS
#define DOUBLE_ALIGNED(sz)   (((sz) % 8) == 0 ? (sz) : (sz)+(8-((sz)%8)))
#define ERROR_VALUE   -1
#define ERROR_RETURN   Error_Return_Func()
#define CHECK_INPUT_FILES
#define CONVERT_OFFSET(typ, fld)

Functions

INT Error_Return_Func (void)
template<class Shdr >
const Shdr * get_section_header (const Shdr *shdr, UINT n, Elf64_Word type, Elf64_Word info)
OFFSET_AND_SIZE get_section (void *handle, Elf64_Word type, Elf64_Word info)
INT WN_get_global_symtab (void *handle)
INT WN_get_symtab (void *handle, PU_Info *pu)
INT WN_get_strtab (void *handle)
static INT fix_tree (WN *node, char *base, Elf64_Word size)
void Set_Verbose_Info (BOOL val)
template<class ELF >
INT check_elf_header (const char *baseaddr, Elf64_Word size, const ELF &tag)
static INT check_elf_header (const char *baseaddr, Elf64_Word size)
template<class ELF >
INT check_section_headers (char *baseaddr, Elf64_Word size, char *file_revision, const ELF &tag)
static INT fix_comp_flags (char *base, Elf64_Word size)
INT WN_massage_input (char *baseaddr, Elf64_Word size, char *file_revision)
static void * read_file (const char *filename, off_t *mapped_size, char *file_revision)
Elf64_Word Get_Elf_Section_Size (void *handle, Elf64_Word type, Elf64_Word info)
void * WN_open_input (const char *filename, off_t *mapped_size)
void * WN_inline_open_file (const char *file_name, off_t *mapped_size, char *file_revision)
PU_InfoWN_get_PU_Infos (void *handle, INT32 *p_num_PUs)
void * WN_get_section_base (void *handle, INT sect)
STWN_get_proc_sym (PU_Info *pu)
WNWN_get_tree (void *handle, PU_Info *pu)
INT WN_get_flags (void *handle, char ***argv)
INT WN_get_dst (void *handle)
INT WN_get_feedback (void *handle, PU_Info *pu, MEM_POOL *pool)
INT WN_get_prefetch (void *handle, PU_Info *pu)
static void WN_MAP_put (WN_MAP wn_map, WN *wn, INT32 value)
static void WN_MAP_put (WN_MAP wn_map, WN *wn, INT64 value)
static void WN_MAP_put (WN_MAP wn_map, WN *wn, void *value)
template<class MAP_ENTRY_TYPE >
static INT WN_read_generic_map (void *handle, PU_Info *pu, INT32 subsection_type, WN_MAP value_map, MAP_ENTRY_TYPE)
INT WN_get_INT32_map (void *handle, PU_Info *pu, INT32 subsection_type, WN_MAP value_map)
INT WN_get_voidptr_map (void *handle, PU_Info *pu, INT32 subsection_type, WN_MAP value_map)
void WN_free_input (void *handle, off_t mapped_size)
static void open_specified_input (const char *input_file, const char **ir_input, void **fhandle, off_t *mapped_size)
void * Open_Input_Info (const char *input_file)
void * Open_Global_Input (const char *input_file)
void * Open_Local_Input (const char *input_file)
PU_InfoRead_Global_Info (INT32 *p_num_PUs)
void Read_Local_Info (MEM_POOL *pool, PU_Info *pu)
void Free_Local_Info (PU_Info *pu)
void Free_Local_Input (void)
void Free_Input_Info (void)

Variables

static BOOL verbose_info = FALSE
static WNlast_node = NULL
static off_t global_mapped_size
static off_t local_mapped_size
static char file_revision [80]
static void * global_fhandle
static void * local_fhandle
static const char * global_ir_file
static const char * local_ir_file

Define Documentation

Definition at line 180 of file ir_bread.cxx.

#define CONVERT_OFFSET (   typ,
  fld 
)
Value:
if ((INTPTR)(fld) >= size) return ERROR_RETURN; \
    else (fld) = (typ)(base + (INTPTR)(fld))

Definition at line 185 of file ir_bread.cxx.

Referenced by fix_tree(), and WN_get_dst().

#define DOUBLE_ALIGNED (   sz)    (((sz) % 8) == 0 ? (sz) : (sz)+(8-((sz)%8)))

Definition at line 103 of file ir_bread.cxx.

Definition at line 77 of file ir_bread.cxx.

#define USE_STANDARD_TYPES   /* override unwanted defines in "defs.h" */

Definition at line 48 of file ir_bread.cxx.


Function Documentation

template<class ELF >
INT check_elf_header ( const char *  baseaddr,
Elf64_Word  size,
const ELF &  tag 
)

Definition at line 501 of file ir_bread.cxx.

References ABI_MISMATCH, ABI_UNDEF, ALIGNOF, Config_Target_From_ELF(), EI_VERSION, ERROR_RETURN, ET_IR, EV_CURRENT, Get_Elf_Target_Machine(), Set_Target_ABI(), and Target_ABI.

Referenced by check_elf_header(), and WN_massage_input().

Here is the call graph for this function:

static INT check_elf_header ( const char *  baseaddr,
Elf64_Word  size 
) [static]

Definition at line 538 of file ir_bread.cxx.

References check_elf_header(), Elf64_Ehdr::e_ident, EI_CLASS, ELFCLASS32, ELFCLASS64, ERROR_RETURN, and IS_ELF.

Here is the call graph for this function:

template<class ELF >
INT check_section_headers ( char *  baseaddr,
Elf64_Word  size,
char *  file_revision,
const ELF &  tag 
)
INT Error_Return_Func ( void  )

Definition at line 112 of file ir_bread.cxx.

References ERROR_VALUE, NULL, OPCODE_name(), verbose_info, and WN_opcode().

Here is the call graph for this function:

static INT fix_comp_flags ( char *  base,
Elf64_Word  size 
) [static]

Definition at line 622 of file ir_bread.cxx.

References ERROR_RETURN.

Referenced by WN_get_flags().

void Free_Input_Info ( void  )

Definition at line 1371 of file ir_bread.cxx.

References Free_Local_Input(), global_fhandle, global_mapped_size, local_fhandle, and WN_free_input().

Referenced by Cleanup_Files(), ir_b2a(), ir_sel(), and ir_size().

Here is the call graph for this function:

void Free_Local_Info ( PU_Info pu)

Definition at line 1352 of file ir_bread.cxx.

References Delete_Scope(), NULL, PU_Info_maptab, PU_Info_proc_sym, PU_lexical_level(), St_Table, and WN_MAP_TAB_Delete().

Referenced by ir_b2a_process_PUs(), ir_sel(), main(), Postprocess_PU(), and process_pu().

Here is the call graph for this function:

void Free_Local_Input ( void  )

Definition at line 1364 of file ir_bread.cxx.

References local_fhandle, local_mapped_size, and WN_free_input().

Referenced by Free_Input_Info().

Here is the call graph for this function:

Elf64_Word Get_Elf_Section_Size ( void *  handle,
Elf64_Word  type,
Elf64_Word  info 
)

Definition at line 714 of file ir_bread.cxx.

References get_section(), OFFSET_AND_SIZE::offset, and OFFSET_AND_SIZE::size.

Referenced by ir_size().

Here is the call graph for this function:

template<class Shdr >
const Shdr* get_section_header ( const Shdr *  shdr,
UINT  n,
Elf64_Word  type,
Elf64_Word  info 
)

Definition at line 129 of file ir_bread.cxx.

References NULL.

Referenced by get_section().

void* Open_Global_Input ( const char *  input_file)

Definition at line 1245 of file ir_bread.cxx.

References global_fhandle, global_ir_file, global_mapped_size, and open_specified_input().

Referenced by ir_b2a(), and main().

Here is the call graph for this function:

void* Open_Input_Info ( const char *  input_file)

Definition at line 1234 of file ir_bread.cxx.

References global_fhandle, global_ir_file, global_mapped_size, local_fhandle, local_ir_file, local_mapped_size, and open_specified_input().

Referenced by ir_b2a(), ir_sel(), ir_size(), and main().

Here is the call graph for this function:

void* Open_Local_Input ( const char *  input_file)

Definition at line 1253 of file ir_bread.cxx.

References local_fhandle, local_ir_file, local_mapped_size, and open_specified_input().

Referenced by ir_b2a(), and main().

Here is the call graph for this function:

static void open_specified_input ( const char *  input_file,
const char **  ir_input,
void **  fhandle,
off_t *  mapped_size 
) [static]

Definition at line 1214 of file ir_bread.cxx.

References ABI_MISMATCH, EC_IR_Open, EC_IR_Revision, ErrMsg(), errno, file_revision, READER_ERROR, REVISION_MISMATCH, Set_Error_Phase(), and WN_open_input().

Referenced by Open_Global_Input(), Open_Input_Info(), and Open_Local_Input().

Here is the call graph for this function:

static void* read_file ( const char *  filename,
off_t *  mapped_size,
char *  file_revision 
) [static]

Definition at line 677 of file ir_bread.cxx.

References close, ERROR_RETURN, ERROR_VALUE, fd, fstat, open, stat, and WN_massage_input().

Referenced by WN_inline_open_file(), and WN_open_input().

Here is the call graph for this function:

void Set_Verbose_Info ( BOOL  val)

Definition at line 493 of file ir_bread.cxx.

References val, and verbose_info.

Referenced by main().

void WN_free_input ( void *  handle,
off_t  mapped_size 
)

Definition at line 1192 of file ir_bread.cxx.

Referenced by Free_Input_Info(), and Free_Local_Input().

INT WN_get_dst ( void *  handle)

Definition at line 923 of file ir_bread.cxx.

References CONVERT_OFFSET, Current_DST, DST_Init(), ERROR_RETURN, get_section(), NULL, OFFSET_AND_SIZE::offset, SHT_MIPS_WHIRL, OFFSET_AND_SIZE::size, size, and WT_DST.

Referenced by Read_Global_Info().

Here is the call graph for this function:

INT WN_get_flags ( void *  handle,
char ***  argv 
)

Definition at line 898 of file ir_bread.cxx.

References ERROR_VALUE, fix_comp_flags(), get_section(), if(), OFFSET_AND_SIZE::offset, SHT_MIPS_WHIRL, OFFSET_AND_SIZE::size, and WT_COMP_FLAGS.

Here is the call graph for this function:

INT WN_get_INT32_map ( void *  handle,
PU_Info pu,
INT32  subsection_type,
WN_MAP  value_map 
)

Definition at line 1164 of file ir_bread.cxx.

References WN_read_generic_map().

Referenced by Read_Local_Info().

Here is the call graph for this function:

PU_Info* WN_get_PU_Infos ( void *  handle,
INT32 p_num_PUs 
)

Definition at line 770 of file ir_bread.cxx.

References ERROR_RETURN, ERROR_VALUE, get_section(), OFFSET_AND_SIZE::offset, Read_PU_Infos(), SHT_MIPS_WHIRL, OFFSET_AND_SIZE::size, size, and WT_PU_SECTION.

Referenced by ir_size(), and Read_Global_Info().

Here is the call graph for this function:

void* WN_get_section_base ( void *  handle,
INT  sect 
)

Definition at line 792 of file ir_bread.cxx.

References ERROR_RETURN, get_section(), OFFSET_AND_SIZE::offset, return(), and SHT_MIPS_WHIRL.

Here is the call graph for this function:

INT WN_get_strtab ( void *  handle)

Definition at line 380 of file ir_bread.cxx.

References ERROR_RETURN, get_section(), Initialize_Strtab(), OFFSET_AND_SIZE::offset, SHT_MIPS_WHIRL, OFFSET_AND_SIZE::size, and WT_STRTAB.

Referenced by Read_Global_Info().

Here is the call graph for this function:

INT WN_get_voidptr_map ( void *  handle,
PU_Info pu,
INT32  subsection_type,
WN_MAP  value_map 
)

Definition at line 1174 of file ir_bread.cxx.

References WN_read_generic_map().

Referenced by Read_Local_Info().

Here is the call graph for this function:

void* WN_inline_open_file ( const char *  file_name,
off_t *  mapped_size,
char *  file_revision 
)

Definition at line 748 of file ir_bread.cxx.

References errno, ERROR_RETURN, and read_file().

Here is the call graph for this function:

static void WN_MAP_put ( WN_MAP  wn_map,
WN wn,
INT32  value 
) [inline, static]

Definition at line 1074 of file ir_bread.cxx.

References WN_MAP32_Set.

Referenced by WN_read_generic_map().

static void WN_MAP_put ( WN_MAP  wn_map,
WN wn,
INT64  value 
) [inline, static]

Definition at line 1080 of file ir_bread.cxx.

References WN_MAP64_Set.

static void WN_MAP_put ( WN_MAP  wn_map,
WN wn,
void *  value 
) [inline, static]

Definition at line 1086 of file ir_bread.cxx.

References WN_MAP_Set.

INT WN_massage_input ( char *  baseaddr,
Elf64_Word  size,
char *  file_revision 
)

Definition at line 651 of file ir_bread.cxx.

References check_elf_header(), check_section_headers(), and ELFCLASS32.

Referenced by read_file().

Here is the call graph for this function:

void* WN_open_input ( const char *  filename,
off_t *  mapped_size 
)

Definition at line 729 of file ir_bread.cxx.

References errno, ERROR_RETURN, file_revision, and read_file().

Referenced by open_specified_input().

Here is the call graph for this function:

template<class MAP_ENTRY_TYPE >
static INT WN_read_generic_map ( void *  handle,
PU_Info pu,
INT32  subsection_type,
WN_MAP  value_map,
MAP_ENTRY_TYPE   
) [inline, static]

Variable Documentation

char file_revision[80] [static]

Definition at line 100 of file ir_bread.cxx.

Referenced by open_specified_input(), and WN_open_input().

void* global_fhandle [static]
const char* global_ir_file [static]

Definition at line 1210 of file ir_bread.cxx.

Referenced by Open_Global_Input(), Open_Input_Info(), and Read_Global_Info().

off_t global_mapped_size [static]

Definition at line 97 of file ir_bread.cxx.

Referenced by Free_Input_Info(), Open_Global_Input(), and Open_Input_Info().

const char* local_ir_file [static]
off_t local_mapped_size [static]

Definition at line 98 of file ir_bread.cxx.

Referenced by Free_Local_Input(), Open_Input_Info(), and Open_Local_Input().

BOOL verbose_info = FALSE [static]

Definition at line 94 of file ir_bread.cxx.

Referenced by Error_Return_Func(), fix_tree(), Read_Global_Info(), and Set_Verbose_Info().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines