/* Subroutines for the gcc driver.
Copyright (C) 2021-2022 Free Software Foundation, Inc.
Contributed by Loongson Ltd.
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
. */
#define IN_TARGET_CODE 1
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "obstack.h"
#include "diagnostic-core.h"
#include "loongarch-opts.h"
#include "loongarch-driver.h"
static int
opt_arch_driver = M_OPTION_NOT_SEEN,
opt_tune_driver = M_OPTION_NOT_SEEN,
opt_fpu_driver = M_OPTION_NOT_SEEN,
opt_abi_base_driver = M_OPTION_NOT_SEEN,
opt_abi_ext_driver = M_OPTION_NOT_SEEN,
opt_cmodel_driver = M_OPTION_NOT_SEEN;
int opt_switches = 0;
/* This flag is set to 1 if we believe that the user might be avoiding
linking (implicitly) against something from the startfile search paths. */
static int no_link = 0;
#define LARCH_DRIVER_SET_M_FLAG(OPTS_ARRAY, N_OPTS, FLAG, STR) \
for (int i = 0; i < (N_OPTS); i++) \
{ \
if ((OPTS_ARRAY)[i] != 0) \
if (strcmp ((STR), (OPTS_ARRAY)[i]) == 0) \
(FLAG) = i; \
}
/* Use the public obstack from the gcc driver (defined in gcc.c).
This is for allocating space for the returned string. */
extern struct obstack opts_obstack;
#define APPEND_LTR(S) \
obstack_grow (&opts_obstack, (const void*) (S), \
sizeof ((S)) / sizeof (char) -1)
#define APPEND_VAL(S) \
obstack_grow (&opts_obstack, (const void*) (S), strlen ((S)))
const char*
driver_set_m_flag (int argc, const char **argv)
{
int parm_off = 0;
if (argc != 1)
return "%eset_m_flag requires exactly 1 argument.";
#undef PARM
#define PARM (argv[0] + parm_off)
/* Note: sizeof (OPTSTR_##NAME) equals the length of "