diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-01-01 12:30:20 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-01-01 12:30:20 +0100 |
commit | f171b7a717b3cb576a36a87bdd72eb8169e24f91 (patch) | |
tree | f71063a3db82fb868d179369f296c76d5a636e46 /src/ghdldrv | |
parent | 02180694190081362a013e96ab18e22d49600600 (diff) | |
download | ghdl-f171b7a717b3cb576a36a87bdd72eb8169e24f91.tar.gz ghdl-f171b7a717b3cb576a36a87bdd72eb8169e24f91.tar.bz2 ghdl-f171b7a717b3cb576a36a87bdd72eb8169e24f91.zip |
vhdl: handle -gGEN=VAL for --synth. Fix #1062
Diffstat (limited to 'src/ghdldrv')
-rw-r--r-- | src/ghdldrv/ghdllocal.adb | 71 | ||||
-rw-r--r-- | src/ghdldrv/ghdllocal.ads | 8 | ||||
-rw-r--r-- | src/ghdldrv/ghdlsynth.adb | 12 |
3 files changed, 86 insertions, 5 deletions
diff --git a/src/ghdldrv/ghdllocal.adb b/src/ghdldrv/ghdllocal.adb index 08307d7eb..79a6d0006 100644 --- a/src/ghdldrv/ghdllocal.adb +++ b/src/ghdldrv/ghdllocal.adb @@ -56,6 +56,68 @@ package body Ghdllocal is Compile_Init; end Init; + function Is_Generic_Override_Option (Opt : String) return Boolean + is + pragma Assert (Opt'First = 1); + begin + if Opt (1 .. 2) /= "-g" then + return False; + end if; + -- Look for '='. + for I in 3 .. Opt'Last loop + if Opt (I) = '=' then + -- Ideally, OPT must be of the form -gGEN=VAL, where GEN is + -- a generic name, and VAL a literal. + return True; + end if; + end loop; + return False; + end Is_Generic_Override_Option; + + function Decode_Generic_Override_Option (Opt : String) return Option_State + is + use Errorout; + pragma Assert (Opt'First = 1); + pragma Assert (Opt'Last >= 5); + Eq_Pos : Natural; + Id : Name_Id; + begin + Eq_Pos := 0; + for I in 3 .. Opt'Last loop + if Opt (I) = '=' then + Eq_Pos := I; + exit; + end if; + end loop; + if Eq_Pos = 0 then + Error_Msg_Option ("missing '=' in generic override option"); + return Option_Err; + elsif Eq_Pos < 3 then + Error_Msg_Option ("missing generic name in generic override option"); + return Option_Err; + elsif Eq_Pos = Opt'Last then + Error_Msg_Option ("missing value in generic override option"); + return Option_Err; + end if; + + declare + Res : String (1 .. Eq_Pos - 3) := Opt (3 .. Eq_Pos - 1); + Err : Boolean; + begin + Vhdl.Scanner.Convert_Identifier (Res, Err); + if Err then + Error_Msg_Option + ("incorrect generic name in generic override option"); + return Option_Err; + end if; + Id := Name_Table.Get_Identifier (Res); + end; + + Vhdl.Configuration.Add_Generic_Override + (Id, Opt (Eq_Pos + 1 .. Opt'Last)); + return Option_Ok; + end Decode_Generic_Override_Option; + function Decode_Driver_Option (Opt : String) return Option_State is pragma Assert (Opt'First = 1); @@ -74,10 +136,13 @@ package body Ghdllocal is Flag_Ieee := Lib_Standard; elsif Opt = "-m32" then Flag_32bit := True; - elsif Opt'Length >= 2 - and then (Opt (2) = 'g' or Opt (2) = 'O') + elsif Opt'Length >= 2 and then Opt (2) = 'O' then + -- Silently accept -O + null; + elsif Opt'Length >= 2 and then Opt (2) = 'g' + and then not Is_Generic_Override_Option (Opt) then - -- Silently accept -g and -O. + -- Silently accept -g (if this is not a generic override option). null; else return Options.Parse_Option (Opt); diff --git a/src/ghdldrv/ghdllocal.ads b/src/ghdldrv/ghdllocal.ads index ffaceabf9..042c51d87 100644 --- a/src/ghdldrv/ghdllocal.ads +++ b/src/ghdldrv/ghdllocal.ads @@ -148,5 +148,13 @@ package Ghdllocal is Prim_Id : out Name_Id; Sec_Id : out Name_Id); + -- Report true iff OPT has the form '-gGEN=VAL'. Used to distingish from + -- debugging (like '-g' or '-ggdb' or '-g2') options. + function Is_Generic_Override_Option (Opt : String) return Boolean; + + -- Handle generic override option OPT. Return Option_Err if the generic + -- name is incorrect. + function Decode_Generic_Override_Option (Opt : String) return Option_State; + procedure Register_Commands; end Ghdllocal; diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb index 31ab180ab..c87405ca3 100644 --- a/src/ghdldrv/ghdlsynth.adb +++ b/src/ghdldrv/ghdlsynth.adb @@ -87,9 +87,16 @@ package body Ghdlsynth is procedure Decode_Option (Cmd : in out Command_Synth; Option : String; Arg : String; - Res : out Option_State) is + Res : out Option_State) + is + pragma Assert (Option'First = 1); begin - if Option = "--disp-noinline" then + if Option'Last > 3 + and then Option (2) = 'g' + and then Is_Generic_Override_Option (Option) + then + Res := Decode_Generic_Override_Option (Option); + elsif Option = "--disp-noinline" then Cmd.Disp_Inline := False; Res := Option_Ok; elsif Option = "--disp-noid" then @@ -237,6 +244,7 @@ package body Ghdlsynth is Entity : constant Iir := Vhdl.Utils.Get_Entity_From_Configuration (Config); begin + Vhdl.Configuration.Apply_Generic_Override (Entity); Vhdl.Configuration.Check_Entity_Declaration_Top (Entity, False); if Nbr_Errors > 0 then return Null_Iir; |