Mercurial > projects > ldc
annotate gen/programs.cpp @ 1320:1ad5a58b5c9d
Restrict second arg of certain floating-point stores to ST. Fix type postfix
for the two argument form of fistp and fisttp.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 09 May 2009 08:58:41 +0200 |
parents | 847b767b2d0b |
children | a376776e2301 |
rev | line source |
---|---|
1299
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
1 #include "gen/programs.h" |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
2 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
3 #include "llvm/Support/CommandLine.h" |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
4 #include "llvm/System/Program.h" |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
5 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
6 #include "root.h" // error(char*) |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
7 #include "mars.h" // fatal() |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
8 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
9 using namespace llvm; |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
10 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
11 static cl::opt<std::string> gcc("gcc", |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
12 cl::desc("GCC to use for assembling and linking"), |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
13 cl::Hidden, |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
14 cl::ZeroOrMore); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
15 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
16 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
17 sys::Path getGcc() { |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
18 const char *cc = NULL; |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
19 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
20 if (gcc.getNumOccurrences() > 0 && gcc.length() > 0) |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
21 cc = gcc.c_str(); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
22 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
23 if (!cc) |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
24 #if !_WIN32 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
25 cc = getenv("CC"); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
26 if (!cc) |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
27 #endif |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
28 cc = "gcc"; |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
29 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
30 sys::Path path = sys::Program::FindProgramByName(cc); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
31 if (path.empty() && !cc) { |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
32 if (cc) { |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
33 path.set(cc); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
34 } else { |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
35 error("failed to locate gcc"); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
36 fatal(); |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
37 } |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
38 } |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
39 |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
40 return path; |
847b767b2d0b
Factor out the code to find gcc, and add a command-line option to override the
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
41 } |