GCC Middle and Back End API Reference
genopinit.c File Reference
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "errors.h"
#include "gensupport.h"
#include "rtl.def"
#include "optabs.def"
Include dependency graph for genopinit.c:

Data Structures

struct  optab_def_d
struct  pattern_d

Macros

#define DEF_RTL_EXPR(V, N, X, C)   #V,
#define OPTAB_CL(name, pat, c, b, l)   name,
#define OPTAB_CX(name, pat)
#define OPTAB_CD(name, pat)   name,
#define OPTAB_NL(name, pat, c, b, s, l)   name,
#define OPTAB_NC(name, pat, c)   name,
#define OPTAB_NX(name, pat)
#define OPTAB_VL(name, pat, c, b, s, l)   name,
#define OPTAB_VC(name, pat, c)   name,
#define OPTAB_VX(name, pat)
#define OPTAB_DC(name, pat, c)   name,
#define OPTAB_D(name, pat)   name,
#define NS   "NULL"
#define ZS   "'\\0'"
#define OPTAB_CL(o, p, c, b, l)   { #o, p, #b, ZS, #l, o, c, UNKNOWN, 1 },
#define OPTAB_CX(o, p)   { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 1 },
#define OPTAB_CD(o, p)   { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 2 },
#define OPTAB_NL(o, p, c, b, s, l)   { #o, p, #b, #s, #l, o, c, c, 3 },
#define OPTAB_NC(o, p, c)   { #o, p, NS, ZS, NS, o, c, c, 3 },
#define OPTAB_NX(o, p)   { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
#define OPTAB_VL(o, p, c, b, s, l)   { #o, p, #b, #s, #l, o, c, UNKNOWN, 3 },
#define OPTAB_VC(o, p, c)   { #o, p, NS, ZS, NS, o, c, UNKNOWN, 3 },
#define OPTAB_VX(o, p)   { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
#define OPTAB_DC(o, p, c)   { #o, p, NS, ZS, NS, o, c, c, 4 },
#define OPTAB_D(o, p)   { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 4 },

Typedefs

typedef enum optab_tag optab
typedef struct optab_def_d optab_def
typedef struct pattern_d pattern

Enumerations

enum  optab_tag { unknown_optab, NUM_OPTABS }

Functions

static bool match_pattern ()
static void gen_insn ()
static int pattern_cmp ()
static int optab_kind_cmp ()
static int optab_rcode_cmp ()
static bool handle_arg ()
static FILE * open_outfile ()
int main ()

Variables

static const char *const rtx_upname []
static optab_def optabs []
static vec< patternpatterns
static const char * header_file_name = "init-opinit.h"
static const char * source_file_name = "init-opinit.c"

Macro Definition Documentation

#define DEF_RTL_EXPR (   V,
  N,
  X,
 
)    #V,

Generate code to initialize optabs from machine description. Copyright (C) 1993-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

#define NS   "NULL"
#define OPTAB_CD (   name,
  pat 
)    name,
#define OPTAB_CD (   o,
 
)    { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 2 },
#define OPTAB_CL (   name,
  pat,
  c,
  b,
 
)    name,

The entries in optabs.def are categorized: C: A "conversion" optab, which uses two modes; has libcall data. N: A "normal" optab, which uses one mode; has libcall data. D: A "direct" optab, which uses one mode; does not have libcall data. V: An "oVerflow" optab. Like N, but does not record its code in code_to_optab.

CX, NX, VX: An extra pattern entry for a conversion or normal optab.

These patterns may be present in the MD file with names that contain the mode(s) used and the name of the operation. This array contains a list of optabs that need to be initialized. Within each name, $a and $b are used to match a short mode name (the part of the mode name not including `mode' and converted to lower-case).

$I means that only full integer modes should be considered for the next mode, and $F means that only float modes should be considered. $P means that both full and partial integer modes should be considered. $Q means that only fixed-point modes should be considered.

The pattern may be NULL if the optab exists only for the libcalls that we plan to attach to it, and there are no named patterns in the md files.

#define OPTAB_CL (   o,
  p,
  c,
  b,
 
)    { #o, p, #b, ZS, #l, o, c, UNKNOWN, 1 },

The entries in optabs.def are categorized: C: A "conversion" optab, which uses two modes; has libcall data. N: A "normal" optab, which uses one mode; has libcall data. D: A "direct" optab, which uses one mode; does not have libcall data. V: An "oVerflow" optab. Like N, but does not record its code in code_to_optab.

CX, NX, VX: An extra pattern entry for a conversion or normal optab.

These patterns may be present in the MD file with names that contain the mode(s) used and the name of the operation. This array contains a list of optabs that need to be initialized. Within each name, $a and $b are used to match a short mode name (the part of the mode name not including `mode' and converted to lower-case).

$I means that only full integer modes should be considered for the next mode, and $F means that only float modes should be considered. $P means that both full and partial integer modes should be considered. $Q means that only fixed-point modes should be considered.

The pattern may be NULL if the optab exists only for the libcalls that we plan to attach to it, and there are no named patterns in the md files.

#define OPTAB_CX (   name,
  pat 
)
#define OPTAB_CX (   o,
 
)    { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 1 },
#define OPTAB_D (   name,
  pat 
)    name,
#define OPTAB_D (   o,
 
)    { #o, p, NS, ZS, NS, o, UNKNOWN, UNKNOWN, 4 },
#define OPTAB_DC (   name,
  pat,
 
)    name,
#define OPTAB_DC (   o,
  p,
 
)    { #o, p, NS, ZS, NS, o, c, c, 4 },
#define OPTAB_NC (   name,
  pat,
 
)    name,
#define OPTAB_NC (   o,
  p,
 
)    { #o, p, NS, ZS, NS, o, c, c, 3 },
#define OPTAB_NL (   name,
  pat,
  c,
  b,
  s,
 
)    name,
#define OPTAB_NL (   o,
  p,
  c,
  b,
  s,
 
)    { #o, p, #b, #s, #l, o, c, c, 3 },
#define OPTAB_NX (   name,
  pat 
)
#define OPTAB_NX (   o,
 
)    { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
#define OPTAB_VC (   name,
  pat,
 
)    name,
#define OPTAB_VC (   o,
  p,
 
)    { #o, p, NS, ZS, NS, o, c, UNKNOWN, 3 },
#define OPTAB_VL (   name,
  pat,
  c,
  b,
  s,
 
)    name,
#define OPTAB_VL (   o,
  p,
  c,
  b,
  s,
 
)    { #o, p, #b, #s, #l, o, c, UNKNOWN, 3 },
#define OPTAB_VX (   name,
  pat 
)
#define OPTAB_VX (   o,
 
)    { #o, p, NULL, NULL, NULL, o, UNKNOWN, UNKNOWN, 3 },
#define ZS   "'\\0'"

Typedef Documentation

typedef enum optab_tag optab
typedef struct optab_def_d optab_def
typedef struct pattern_d pattern

Vector in which to collect insns that match.


Enumeration Type Documentation

enum optab_tag
Enumerator:
unknown_optab 
NUM_OPTABS 

Definitions for operation tables, or "optabs". Copyright (C) 1987-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Entries here are categorized C, D, N, V. See genopinit.c for details on the meaning of the categories and for the pattern dollar codes. The extension libcalls are used for float extension. Conversions for fixed-point modes and other modes. Misc optabs that use two modes, model them as "conversions". Comparison libcalls for integers MUST come in pairs, signed/unsigned. EQ etc are floating point comparisons. These are all initialized individually, on a per-host basis.


Function Documentation

static void gen_insn ( )
static

Don't mention "unnamed" instructions.

 See if NAME matches one of the patterns we have for the optabs
 we know about.   
static bool handle_arg ( )
static
int main ( )
 Read the machine description.   
 Sort the collected patterns.   
 Now that we've handled the "extra" patterns, eliminate them from
 the optabs array.  That way they don't get in the way below.   
 Sort the (real) optabs.  Better than forcing the optabs.def file to
 remain sorted by kind.  We also scrogged any real ordering with the
 purging of the X patterns above.   
 Emit the optab enumeration for the header file.   
 Perform a binary search on a pre-encoded optab+mode*2.   
 ??? Perhaps even better to generate a minimal perfect hash.
 Using gperf directly is awkward since it's so geared to working
 with strings.  Plus we have no visibility into the ordering of
 the hash entries, which complicates the pat_enable array.   
 C++ (even G++) does not support (non-trivial) designated initializers.
 To work around that, generate these arrays programatically rather than
 by our traditional multiple inclusion of def files.   
static bool match_pattern ( )
static

This loop will stop at the first prefix match, so look through the modes in reverse order, in case there are extra CC modes and CC is a prefix of the CC modes (as it should be).

References gcc_unreachable, GET_MODE_NAME, pattern_d::m1, and pattern_d::m2.

static FILE* open_outfile ( )
static
static int optab_kind_cmp ( )
static
static int optab_rcode_cmp ( )
static
static int pattern_cmp ( )
static

References optab_def_d::kind.


Variable Documentation

const char* header_file_name = "init-opinit.h"
static
optab_def optabs[]
static
vec<pattern> patterns
static
const char* const rtx_upname[]
static
const char* source_file_name = "init-opinit.c"
static