coptions.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 2,108 行 · 第 1/5 页

C
2,108
字号
static void Set_ZGP( void )         { SwData.peg_gs_used = 1; SwData.peg_gs_on = 1; }
#endif
static void Set_ZE( void )          { CompFlags.extensions_enabled = 1; }
static void Set_ZG( void )
{
    CompFlags.generate_prototypes = 1;
    CompFlags.dump_prototypes     = 1;
}

static void Set_ZI( void )          { CompFlags.extra_stats_wanted = 1; }

static void Set_ZK( void )          { character_encoding = ENC_ZK; }
static void Set_ZK0( void )         { character_encoding = ENC_ZK0; }
static void Set_ZK1( void )         { character_encoding = ENC_ZK1; }
static void Set_ZK2( void )         { character_encoding = ENC_ZK2; }
static void Set_ZK3( void )         { character_encoding = ENC_ZK3; }
static void Set_ZKL( void )         { character_encoding = ENC_ZKL; }
static void Set_ZKU( void )
{
    character_encoding = ENC_ZKU;
    unicode_CP = OptValue;
}
static void Set_ZK0U( void )        { character_encoding = ENC_ZK0U; }

static void Set_ZL( void )          { CompFlags.emit_library_with_main = 0; }
static void Set_ZLF( void )         { CompFlags.emit_library_any  = 1; }
static void Set_ZLD( void )         { CompFlags.emit_dependencies = 0; }
static void Set_ZLS( void )         { CompFlags.emit_targimp_symbols = 0; }
static void Set_ZEV( void )         { CompFlags.unix_ext = 1; }
static void Set_ZM( void )
{
    CompFlags.multiple_code_segments = 1;
    CompFlags.zm_switch_used = 1;
}
static void Set_ZPW( void )         { CompFlags.slack_byte_warning = 1; }

#if _CPU == 8086 || _CPU == 386
static void Set_ZRO( void )
{
    GenSwitches |= FPU_ROUNDING_OMIT;
    GenSwitches &= ~FPU_ROUNDING_INLINE;
}
#endif

#if _CPU == 386
static void Set_ZRI( void )
{
    GenSwitches |= FPU_ROUNDING_INLINE;
    GenSwitches &= ~FPU_ROUNDING_OMIT;
}
#endif

static void Set_ZQ( void )          { CompFlags.quiet_mode = 1; }
static void Set_ZS( void )          { CompFlags.check_syntax = 1; }

#if _CPU == 8086 || _CPU == 386
static void Set_EQ( void )          { CompFlags.no_conmsg  = 1; }

static void Set_ZFW( void )
{
    TargetSwitches |= GEN_FWAIT_386;
}

static void Set_ZU( void )
{
    CompFlags.zu_switch_used = 1;
    TargetSwitches |= FLOATING_SS;
}

#if _CPU == 386
static void Set_ZZ( void )
{
    CompFlags.use_stdcall_at_number = 0;
}
#endif

#if _CPU == 8086
static void ChkSmartWindows( void )
{
    if( tolower(*OptScanPtr) == 's' ) {        /* 22-mar-94 */
        TargetSwitches |= SMART_WINDOWS;
        ++OptScanPtr;
    }
    EnsureEndOfSwitch();
}

static void SetCheapWindows( void )
{
    _SetConstTarg( "cheap_windows" );
    ChkSmartWindows();
}
#endif

static void SetWindows( void )
{
    _SetConstTarg( "windows" );
#if _CPU == 8086
    ChkSmartWindows();
#endif
}
#endif

static void SetGenerateMakeAutoDepend( void )
{
    CompFlags.generate_auto_depend = 1;
    CMemFree( DependFileName );
    DependFileName = GetAFileName();
    if( !DependFileName[0] )
    {
        CMemFree( DependFileName );
        DependFileName = NULL;
    }
}

static void SetAutoDependTarget( void )
{
   // auto set depend yes...
    CompFlags.generate_auto_depend = 1;
    CMemFree( DependTarget );
    DependTarget = GetAFileName();
}

static void SetAutoDependSrcDepend( void )
{
    CompFlags.generate_auto_depend = 1;
    CMemFree( SrcDepName );
    SrcDepName = GetAFileName();
}

static void SetAutoDependHeaderPath( void )
{
    CompFlags.generate_auto_depend = 1;
    CMemFree( DependHeaderPath );
    DependHeaderPath = GetAFileName();
}

static void SetAutoDependForeSlash( void )
{
    DependForceSlash = '/';
}

static void SetAutoDependBackSlash( void )
{
    DependForceSlash = '\\';
}

static void Set_PIL( void )         { CompFlags.cpp_ignore_line = 1; }
static void Set_PL( void )          { CompFlags.cpp_line_wanted = 1; }
static void Set_PC( void )
{
    CompFlags.keep_comments = 1;
    CompFlags.comments_wanted = 1;
}
static void Set_PW( void )
{
    if( OptValue != 0 && OptValue < 20 ) OptValue = 20;
    if( OptValue > 10000 ) OptValue = 10000;
    SetCppWidth( OptValue );
}
static void Set_PreProcChar( void ) { PreProcChar = *OptScanPtr++; }

static void Set_OA( void )          { GenSwitches |= RELAX_ALIAS; }
static void Set_OB( void )          { GenSwitches |= BRANCH_PREDICTION; }
static void Set_OD( void )          { GenSwitches |= NO_OPTIMIZATION; }
static void Set_OE( void )
{
    Inline_Threshold = OptValue;
    Toggles |= TOGGLE_INLINE;
}
#if _CPU == 8086 || _CPU == 386
static void Set_OC( void )          { TargetSwitches |= NO_CALL_RET_TRANSFORM; }
static void Set_OF( void )
{
    TargetSwitches |= NEED_STACK_FRAME;
    if( OptValue != 0 ) {
        WatcallInfo.cclass |= GENERATE_STACK_FRAME;
    }
}
static void Set_OM( void )          { TargetSwitches |= I_MATH_INLINE; }
static void Set_OP( void )          { CompFlags.op_switch_used = 1; } // force floats to memory
#endif
static void Set_OH( void )          { GenSwitches |= SUPER_OPTIMAL; }
static void Set_OK( void )          { GenSwitches |= FLOW_REG_SAVES; }
static void Set_OI( void )          { CompFlags.inline_functions = 1; }
static void Set_OL( void )          { GenSwitches |= LOOP_OPTIMIZATION; }
static void Set_OL_plus( void )     { GenSwitches |= LOOP_OPTIMIZATION | LOOP_UNROLLING; }
static void Set_ON( void )          { GenSwitches |= FP_UNSTABLE_OPTIMIZATION; }
static void Set_OO( void )          { GenSwitches &= ~MEMORY_LOW_FAILS; }
static void Set_OR( void )          { GenSwitches |= INS_SCHEDULING; }
static void Set_OS( void )          { GenSwitches &= ~NO_OPTIMIZATION; OptSize = 100; }
static void Set_OT( void )          { GenSwitches &= ~NO_OPTIMIZATION; OptSize = 0; }
static void Set_OU( void )          { CompFlags.unique_functions = 1; }
static void Set_OX( void )
{
    Toggles &= ~TOGGLE_CHECK_STACK;
    GenSwitches &= ~NO_OPTIMIZATION;
    GenSwitches |= LOOP_OPTIMIZATION | INS_SCHEDULING | BRANCH_PREDICTION;
    CompFlags.inline_functions = 1;
    OptValue = 20; // Otherwise we effectively disable inlining!
    Set_OE();
#if _CPU == 8086 || _CPU == 386
    TargetSwitches |= I_MATH_INLINE;
#endif
}
static void Set_OZ( void )          { GenSwitches |= NULL_DEREF_OK; }

// '=' indicates optional '='
// '#' indicates a decimal numeric value
// '$' indicates identifier
// '@' indicates filename
// '*' indicates additional characters will be scanned by option routine
// if a capital letter appears in the option, then input must match exactly
// otherwise all input characters are changed to lower case before matching

static struct option const Optimization_Options[] = {
    { "a",      0,              Set_OA },
    { "b",      0,              Set_OB },
    { "d",      0,              Set_OD },
    { "e=#",    20,             Set_OE },
#if _CPU == 8086 || _CPU == 386
    { "c",      0,              Set_OC },
    { "f+",     1,              Set_OF },
    { "f",      0,              Set_OF },
    { "m",      0,              Set_OM },
    { "p",      0,              Set_OP },
#endif
    { "h",      0,              Set_OH },
    { "i",      0,              Set_OI },
    { "k",      0,              Set_OK },
    { "l+",     0,              Set_OL_plus },
    { "l",      0,              Set_OL },
    { "n",      0,              Set_ON },
    { "o",      0,              Set_OO },
    { "r",      0,              Set_OR },
    { "s",      0,              Set_OS },
    { "t",      0,              Set_OT },
    { "u",      0,              Set_OU },
    { "x",      0,              Set_OX },
    { "z",      0,              Set_OZ },
    { 0,        0,              0 },
};

static struct option const Preprocess_Options[] = {
    { "c",      0,              Set_PC },
    { "l",      0,              Set_PL },
    { "w=#",    0,              Set_PW },
    { "=",      0,              Set_PreProcChar },
    { "#",      0,              Set_PreProcChar },
    { 0,        0,              0 },
};

static void SetOptimization( void );
static void SetPreprocessOptions( void );
static struct option const CFE_Options[] = {
    { "o*",     0,              SetOptimization },
    { "i=@",    0,              SetInclude },
    { "zq",     0,              Set_ZQ },
    { "q",      0,              Set_ZQ },
#if _CPU == 8086
    { "0",      SW_CPU0,        SetCPU },
    { "1",      SW_CPU1,        SetCPU },
    { "2",      SW_CPU2,        SetCPU },
    { "3",      SW_CPU3,        SetCPU },
    { "4",      SW_CPU4,        SetCPU },
    { "5",      SW_CPU5,        SetCPU },
    { "6",      SW_CPU6,        SetCPU },
#endif
#if _CPU == 386
    { "6r",     SW_CPU6,        SetCPU_xR },
    { "6s",     SW_CPU6,        SetCPU_xS },
    { "6",      SW_CPU6,        SetCPU },
    { "5r",     SW_CPU5,        SetCPU_xR },
    { "5s",     SW_CPU5,        SetCPU_xS },
    { "5",      SW_CPU5,        SetCPU },
    { "4r",     SW_CPU4,        SetCPU_xR },
    { "4s",     SW_CPU4,        SetCPU_xS },
    { "4",      SW_CPU4,        SetCPU },
    { "3r",     SW_CPU3,        SetCPU_xR },
    { "3s",     SW_CPU3,        SetCPU_xS },
    { "3",      SW_CPU3,        SetCPU },
#endif
    { "aa",     0,              Set_AA },
    // more specific commands first ... otherwise the
    // short command sets us up for failure...
    { "adt=@",  0,              SetAutoDependTarget },
    { "adbs",   0,              SetAutoDependBackSlash },
    { "add=@",  0,              SetAutoDependSrcDepend },
    { "adfs",   0,              SetAutoDependForeSlash },
    { "adhp=@", 0,              SetAutoDependHeaderPath },
    { "ad=@",   0,              SetGenerateMakeAutoDepend },
    { "ai",     0,              Set_AI },
    { "aq",     0,              Set_AQ },
#if _CPU == _AXP
    { "as",     0,              Set_AS },
#endif
    { "d0*",    0,              Set_D0 },
    { "d1*",    1,              Set_D1 },
    { "d2*",    2,              Set_D2 },
    { "d3*",    3,              Set_D3 },
    { "d9*",    9,              Set_D9 },
    { "d+*",    0,              SetExtendedDefines },
    { "db",     0,              SetBrowserInfo },
    { "d*",     0,              DefineMacro },
    { "en",     0,              Set_EN },
    { "ep=#",   0,              Set_EP },
    { "ee",     0,              Set_EE },
    { "ef",     0,              Set_EF },
    { "ei",     0,              Set_EI },
    { "em",     0,              Set_EM },
#if _CPU == 8086 || _CPU == 386
    { "ecc",    1,              SetDftCallConv },
    { "ecd",    2,              SetDftCallConv },
    { "ecf",    3,              SetDftCallConv },
    { "eco",    4,              SetDftCallConv },
    { "ecp",    5,              SetDftCallConv },
    { "ecs",    6,              SetDftCallConv },
    { "ecr",    7,              SetDftCallConv },
    { "ecw",    8,              SetDftCallConv },
    { "ec",     0,              Set_EC },
    { "et",     0,              Set_ET },
    { "eq",     0,              Set_EQ },
    { "etp",    0,              Set_ETP },
    { "esp",    0,              Set_ESP },
#endif
#if /*_CPU == 386 ||*/ _CPU == _AXP || _CPU == _PPC || _CPU == _MIPS
    { "eoe",    0,              Set_ELF },
    { "eoc",    0,              Set_COFF },
#endif
#if _CPU == _AXP || _CPU == _PPC || _CPU == _MIPS
    { "el",     0,              Set_EndianLittle },
    { "eb",     0,              Set_EndianBig },
#endif
#if _CPU == 386
    { "eoo",    0,              Set_OMF },
    { "ez",     0,              Set_EZ },
#endif
    { "e=#",    0,              SetErrorLimit },
#if _CPU == 8086 || _CPU == 386
    { "hw",     SW_DF_WATCOM,   Set_DbgFmt },
#endif
    { "hda",    SW_DF_DWARF_A,  Set_DbgFmt },
    { "hdg",    SW_DF_DWARF_G,  Set_DbgFmt },
    { "hd",     SW_DF_DWARF,    Set_DbgFmt },
    { "hc",     SW_DF_CV,       Set_DbgFmt },
#if _CPU == 8086 || _CPU == 386
    { "g=$",    0,              SetGroup },
#endif
    { "lc",     0,              SetAPILogging },
#ifndef NDEBUG
#ifdef ASM_OUTPUT
    { "la",     0,              SetAsmListing },
#endif
#ifdef OWL_LOGGING
    { "lo",     0,              SetOwlLogging },
#endif
#endif
#if _CPU == 8086 || _CPU == 386
    { "ms",     SW_MS,          SetMemoryModel },
    { "mm",     SW_MM,          SetMemoryModel },
    { "mc",     SW_MC,          SetMemoryModel },
    { "ml",     SW_ML,          SetMemoryModel },
#endif
#if _CPU == 8086
    { "mh",     SW_MH,          SetMemoryModel },
#endif
#if _CPU == 386
    { "mf",     SW_MF,          SetMemoryModel },
#endif
#if _CPU == 8086 || _CPU == 386
    { "nc=$",   0,              SetCodeClass },
    { "nd=$",   0,              SetDataSegName },
    { "nt=$",   0,              SetTextSegName },
#endif
    { "nm=$",   0,              SetModuleName },
    { "pil",    0,              Set_PIL },
    { "p*",     0,              SetPreprocessOptions },
    { "rod=@",  0,              SetReadOnlyDir },
#if _CPU == 8086 || _CPU == 386
    { "re",     0,              Set_RE },
    { "ri",     0,              Set_RI },
    { "r",      0,              Set_R },
    { "sg",     0,              Set_SG },
    { "st",     0,              Set_ST },
#endif
#if _CPU == _AXP || _CPU == _MIPS
    { "si",     0,              Set_SI },
#endif
    { "s",      0,              Set_S },
    { "bd",     0,              Set_BD },
    { "bc",     0,              Set_BC },
    { "bg",     0,              Set_BG },
    { "bm",     0,              Set_BM },
#if _CPU != 8086
    { "br",     0,              Set_BR },
#endif
    { "bw",     0,              Set_BW },
    { "bt=$",   0,              Set_BT },
    { "fhq=@",  0,              Set_FHQ },
    { "fh=@",   0,              Set_FH },
    { "fi=@",   0,              Set_FI },
    { "fld",    0,              Set_FLD },
    { "fo=@",   0,              Set_FO },
    { "fr=@",   0,              Set_FR },
    { "fti",    0,              SetTrackInc },
#if _CPU == 8086 || _CPU == 386
    { "fp2",    SW_FPU0,        SetFPU },
    { "fp3",    SW_FPU3,        SetFPU },
    { "fp5",    SW_FPU5,        SetFPU },
    { "fp6",    SW_FPU6,        SetFPU },
    { "fpr",    0,              Set_FPR },
    { "fpi87",  0,              Set_FPI87 },
    { "fpi",    0,              Set_Emu },
    { "fpc",    0,              Set_FPC },
    { "fpd",    0,              Set_FPD },
#endif
    { "j",      0,              SetCharType },
    { "tp=$",   0,              Set_TP },
    { "u$",     0,              Set_U },
    { "v",      0,              Set_V },
    { "wcd=#",  0,              Set_WCD },
    { "wce=#",  0,              Set_WCE },
    { "we",     0,              Set_WE },

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?