Merge from HEAD@222977.
This commit is contained in:
commit
7afd303ca9
@ -70,6 +70,7 @@ void pmem(KINFO *, VARENT *);
|
||||
void pri(KINFO *, VARENT *);
|
||||
void printheader(void);
|
||||
void priorityr(KINFO *, VARENT *);
|
||||
void egroupname(KINFO *, VARENT *);
|
||||
void rgroupname(KINFO *, VARENT *);
|
||||
void runame(KINFO *, VARENT *);
|
||||
void rvar(KINFO *, VARENT *);
|
||||
@ -78,6 +79,7 @@ int s_cputime(KINFO *);
|
||||
int s_label(KINFO *);
|
||||
int s_loginclass(KINFO *);
|
||||
int s_logname(KINFO *);
|
||||
int s_egroupname(KINFO *);
|
||||
int s_rgroupname(KINFO *);
|
||||
int s_runame(KINFO *);
|
||||
int s_systime(KINFO *);
|
||||
|
@ -88,12 +88,19 @@ static VAR var[] = {
|
||||
{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
|
||||
0},
|
||||
{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"egid", "", "gid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"egroup", "", "group", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR,
|
||||
NULL, 0},
|
||||
{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
|
||||
{"etimes", "ELAPSED", NULL, USER, elapseds, NULL, 12, 0, CHAR, NULL, 0},
|
||||
{"euid", "", "uid", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"f", "F", NULL, 0, kvar, NULL, 8, KOFF(ki_flag), INT, "x", 0},
|
||||
{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"gid", "GID", NULL, 0, kvar, NULL, UIDLEN, KOFF(ki_groups),
|
||||
UINT, UIDFMT, 0},
|
||||
{"group", "GROUP", NULL, LJUST, egroupname, s_egroupname,
|
||||
USERLEN, 0, CHAR, NULL, 0},
|
||||
{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"inblk", "INBLK", NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG,
|
||||
"ld", 0},
|
||||
|
@ -340,6 +340,22 @@ s_uname(KINFO *k)
|
||||
return (strlen(user_from_uid(k->ki_p->ki_uid, 0)));
|
||||
}
|
||||
|
||||
void
|
||||
egroupname(KINFO *k, VARENT *ve)
|
||||
{
|
||||
VAR *v;
|
||||
|
||||
v = ve->var;
|
||||
(void)printf("%-*s", v->width,
|
||||
group_from_gid(k->ki_p->ki_groups[0], 0));
|
||||
}
|
||||
|
||||
int
|
||||
s_egroupname(KINFO *k)
|
||||
{
|
||||
return (strlen(group_from_gid(k->ki_p->ki_groups[0], 0)));
|
||||
}
|
||||
|
||||
void
|
||||
rgroupname(KINFO *k, VARENT *ve)
|
||||
{
|
||||
|
11
bin/ps/ps.1
11
bin/ps/ps.1
@ -29,7 +29,7 @@
|
||||
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 18, 2011
|
||||
.Dd June 14, 2011
|
||||
.Dt PS 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -502,6 +502,12 @@ elapsed running time, in decimal integer seconds
|
||||
.It Cm flags
|
||||
the process flags, in hexadecimal (alias
|
||||
.Cm f )
|
||||
.It Cm gid
|
||||
effective group ID (alias
|
||||
.Cm egid )
|
||||
.It Cm group
|
||||
group name (from egid) (alias
|
||||
.Cm egroup )
|
||||
.It Cm inblk
|
||||
total blocks read (alias
|
||||
.Cm inblock )
|
||||
@ -629,7 +635,8 @@ process pointer
|
||||
.It Cm ucomm
|
||||
name to be used for accounting
|
||||
.It Cm uid
|
||||
effective user ID
|
||||
effective user ID (alias
|
||||
.Cm euid )
|
||||
.It Cm upr
|
||||
scheduling priority on return from system call (alias
|
||||
.Cm usrpri )
|
||||
|
@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "mystring.h"
|
||||
#include "alias.h"
|
||||
#include "options.h" /* XXX for argptr (should remove?) */
|
||||
#include "builtins.h"
|
||||
|
||||
#define ATABSIZE 39
|
||||
|
||||
|
@ -43,5 +43,3 @@ struct alias {
|
||||
};
|
||||
|
||||
struct alias *lookupalias(const char *, int);
|
||||
int aliascmd(int, char **);
|
||||
int unaliascmd(int, char **);
|
||||
|
@ -36,4 +36,3 @@
|
||||
|
||||
arith_t arith(const char *);
|
||||
void arith_lex_reset(void);
|
||||
int expcmd(int, char **);
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "../mystring.h"
|
||||
#ifdef SHELL
|
||||
#include "../output.h"
|
||||
#include "builtins.h"
|
||||
#define FILE struct output
|
||||
#undef stdout
|
||||
#define stdout out1
|
||||
@ -75,7 +76,4 @@ pointer stalloc(int);
|
||||
void error(const char *, ...) __printf0like(1, 2);
|
||||
pid_t getjobpgrp(char *);
|
||||
|
||||
int echocmd(int, char **);
|
||||
int testcmd(int, char **);
|
||||
|
||||
extern char *commandname;
|
||||
|
@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "mystring.h"
|
||||
#include "show.h"
|
||||
#include "cd.h"
|
||||
#include "builtins.h"
|
||||
|
||||
static int cdlogical(char *);
|
||||
static int cdphysical(char *);
|
||||
|
@ -30,5 +30,3 @@
|
||||
*/
|
||||
|
||||
void pwd_init(int);
|
||||
int cdcmd (int, char **);
|
||||
int pwdcmd(int, char **);
|
||||
|
@ -571,14 +571,8 @@ evalpipe(union node *n)
|
||||
static int
|
||||
is_valid_fast_cmdsubst(union node *n)
|
||||
{
|
||||
union node *argp;
|
||||
|
||||
if (n->type != NCMD)
|
||||
return 0;
|
||||
for (argp = n->ncmd.args ; argp ; argp = argp->narg.next)
|
||||
if (expandhassideeffects(argp->narg.text))
|
||||
return 0;
|
||||
return 1;
|
||||
return (n->type == NCMD);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -596,6 +590,7 @@ evalbackcmd(union node *n, struct backcmd *result)
|
||||
struct stackmark smark; /* unnecessary */
|
||||
struct jmploc jmploc;
|
||||
struct jmploc *savehandler;
|
||||
struct localvar *savelocalvars;
|
||||
|
||||
setstackmark(&smark);
|
||||
result->fd = -1;
|
||||
@ -608,12 +603,18 @@ evalbackcmd(union node *n, struct backcmd *result)
|
||||
}
|
||||
if (is_valid_fast_cmdsubst(n)) {
|
||||
exitstatus = oexitstatus;
|
||||
savelocalvars = localvars;
|
||||
localvars = NULL;
|
||||
forcelocal++;
|
||||
savehandler = handler;
|
||||
if (setjmp(jmploc.loc)) {
|
||||
if (exception == EXERROR || exception == EXEXEC)
|
||||
exitstatus = 2;
|
||||
else if (exception != 0) {
|
||||
handler = savehandler;
|
||||
forcelocal--;
|
||||
poplocalvars();
|
||||
localvars = savelocalvars;
|
||||
longjmp(handler->loc, 1);
|
||||
}
|
||||
} else {
|
||||
@ -621,6 +622,9 @@ evalbackcmd(union node *n, struct backcmd *result)
|
||||
evalcommand(n, EV_BACKCMD, result);
|
||||
}
|
||||
handler = savehandler;
|
||||
forcelocal--;
|
||||
poplocalvars();
|
||||
localvars = savelocalvars;
|
||||
} else {
|
||||
exitstatus = 0;
|
||||
if (pipe(pip) < 0)
|
||||
|
@ -51,19 +51,10 @@ struct backcmd { /* result of evalbackcmd */
|
||||
#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
|
||||
#define EV_BACKCMD 04 /* command executing within back quotes */
|
||||
|
||||
int evalcmd(int, char **);
|
||||
void evalstring(char *, int);
|
||||
union node; /* BLETCH for ansi C */
|
||||
void evaltree(union node *, int);
|
||||
void evalbackcmd(union node *, struct backcmd *);
|
||||
int bltincmd(int, char **);
|
||||
int breakcmd(int, char **);
|
||||
int returncmd(int, char **);
|
||||
int falsecmd(int, char **);
|
||||
int truecmd(int, char **);
|
||||
int execcmd(int, char **);
|
||||
int timescmd(int, char **);
|
||||
int commandcmd(int, char **);
|
||||
|
||||
/* in_function returns nonzero if we are currently evaluating a function */
|
||||
#define in_function() funcnest
|
||||
|
@ -66,7 +66,6 @@ extern int exerrno; /* last exec error */
|
||||
|
||||
void shellexec(char **, char **, const char *, int) __dead2;
|
||||
char *padvance(const char **, const char *);
|
||||
int hashcmd(int, char **);
|
||||
void find_command(const char *, struct cmdentry *, int, const char *);
|
||||
int find_builtin(const char *, int *);
|
||||
void hashcd(void);
|
||||
@ -75,5 +74,4 @@ void addcmdentry(const char *, struct cmdentry *);
|
||||
void defun(const char *, union node *);
|
||||
int unsetfunc(const char *);
|
||||
int typecmd_impl(int, char **, int, const char *);
|
||||
int typecmd(int, char **);
|
||||
void clearcmdentry(void);
|
||||
|
119
bin/sh/expand.c
119
bin/sh/expand.c
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
/*
|
||||
* Routines to expand arguments to commands. We have to deal with
|
||||
@ -76,6 +77,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "mystring.h"
|
||||
#include "arith.h"
|
||||
#include "show.h"
|
||||
#include "builtins.h"
|
||||
|
||||
/*
|
||||
* Structure specifying which parts of the string should be searched
|
||||
@ -1399,6 +1401,36 @@ get_wc(const char **p)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* See if a character matches a character class, starting at the first colon
|
||||
* of "[:class:]".
|
||||
* If a valid character class is recognized, a pointer to the next character
|
||||
* after the final closing bracket is stored into *end, otherwise a null
|
||||
* pointer is stored into *end.
|
||||
*/
|
||||
static int
|
||||
match_charclass(const char *p, wchar_t chr, const char **end)
|
||||
{
|
||||
char name[20];
|
||||
const char *nameend;
|
||||
wctype_t cclass;
|
||||
|
||||
*end = NULL;
|
||||
p++;
|
||||
nameend = strstr(p, ":]");
|
||||
if (nameend == NULL || nameend - p >= sizeof(name) || nameend == p)
|
||||
return 0;
|
||||
memcpy(name, p, nameend - p);
|
||||
name[nameend - p] = '\0';
|
||||
*end = nameend + 2;
|
||||
cclass = wctype(name);
|
||||
/* An unknown class matches nothing but is valid nevertheless. */
|
||||
if (cclass == 0)
|
||||
return 0;
|
||||
return iswctype(chr, cclass);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns true if the pattern matches the string.
|
||||
*/
|
||||
@ -1406,7 +1438,7 @@ get_wc(const char **p)
|
||||
int
|
||||
patmatch(const char *pattern, const char *string, int squoted)
|
||||
{
|
||||
const char *p, *q;
|
||||
const char *p, *q, *end;
|
||||
char c;
|
||||
wchar_t wc, wc2;
|
||||
|
||||
@ -1430,7 +1462,7 @@ patmatch(const char *pattern, const char *string, int squoted)
|
||||
if (localeisutf8)
|
||||
wc = get_wc(&q);
|
||||
else
|
||||
wc = *q++;
|
||||
wc = (unsigned char)*q++;
|
||||
if (wc == '\0')
|
||||
return 0;
|
||||
break;
|
||||
@ -1487,13 +1519,18 @@ patmatch(const char *pattern, const char *string, int squoted)
|
||||
if (localeisutf8)
|
||||
chr = get_wc(&q);
|
||||
else
|
||||
chr = *q++;
|
||||
chr = (unsigned char)*q++;
|
||||
if (chr == '\0')
|
||||
return 0;
|
||||
c = *p++;
|
||||
do {
|
||||
if (c == CTLQUOTEMARK)
|
||||
continue;
|
||||
if (c == '[' && *p == ':') {
|
||||
found |= match_charclass(p, chr, &end);
|
||||
if (end != NULL)
|
||||
p = end;
|
||||
}
|
||||
if (c == CTLESC)
|
||||
c = *p++;
|
||||
if (localeisutf8 && c & 0x80) {
|
||||
@ -1502,7 +1539,7 @@ patmatch(const char *pattern, const char *string, int squoted)
|
||||
if (wc == 0) /* bad utf-8 */
|
||||
return 0;
|
||||
} else
|
||||
wc = c;
|
||||
wc = (unsigned char)c;
|
||||
if (*p == '-' && p[1] != ']') {
|
||||
p++;
|
||||
while (*p == CTLQUOTEMARK)
|
||||
@ -1514,7 +1551,7 @@ patmatch(const char *pattern, const char *string, int squoted)
|
||||
if (wc2 == 0) /* bad utf-8 */
|
||||
return 0;
|
||||
} else
|
||||
wc2 = *p++;
|
||||
wc2 = (unsigned char)*p++;
|
||||
if ( collate_range_cmp(chr, wc) >= 0
|
||||
&& collate_range_cmp(chr, wc2) <= 0
|
||||
)
|
||||
@ -1620,78 +1657,6 @@ cvtnum(int num, char *buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check statically if expanding a string may have side effects.
|
||||
*/
|
||||
int
|
||||
expandhassideeffects(const char *p)
|
||||
{
|
||||
int c;
|
||||
int arinest;
|
||||
|
||||
arinest = 0;
|
||||
while ((c = *p++) != '\0') {
|
||||
switch (c) {
|
||||
case CTLESC:
|
||||
p++;
|
||||
break;
|
||||
case CTLVAR:
|
||||
c = *p++;
|
||||
/* Expanding $! sets the job to remembered. */
|
||||
if (*p == '!')
|
||||
return 1;
|
||||
if ((c & VSTYPE) == VSASSIGN)
|
||||
return 1;
|
||||
/*
|
||||
* If we are in arithmetic, the parameter may contain
|
||||
* '=' which may cause side effects. Exceptions are
|
||||
* the length of a parameter and $$, $# and $? which
|
||||
* are always numeric.
|
||||
*/
|
||||
if ((c & VSTYPE) == VSLENGTH) {
|
||||
while (*p != '=')
|
||||
p++;
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
if ((*p == '$' || *p == '#' || *p == '?') &&
|
||||
p[1] == '=') {
|
||||
p += 2;
|
||||
break;
|
||||
}
|
||||
if (arinest > 0)
|
||||
return 1;
|
||||
break;
|
||||
case CTLBACKQ:
|
||||
case CTLBACKQ | CTLQUOTE:
|
||||
if (arinest > 0)
|
||||
return 1;
|
||||
break;
|
||||
case CTLARI:
|
||||
arinest++;
|
||||
break;
|
||||
case CTLENDARI:
|
||||
arinest--;
|
||||
break;
|
||||
case '=':
|
||||
if (*p == '=') {
|
||||
/* Allow '==' operator. */
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
if (arinest > 0)
|
||||
return 1;
|
||||
break;
|
||||
case '!': case '<': case '>':
|
||||
/* Allow '!=', '<=', '>=' operators. */
|
||||
if (*p == '=')
|
||||
p++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do most of the work for wordexp(3).
|
||||
*/
|
||||
|
@ -63,5 +63,3 @@ void expari(int);
|
||||
int patmatch(const char *, const char *, int);
|
||||
void rmescapes(char *);
|
||||
int casematch(union node *, const char *);
|
||||
int expandhassideeffects(const char *);
|
||||
int wordexpcmd(int, char **);
|
||||
|
@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "error.h"
|
||||
#include "eval.h"
|
||||
#include "memalloc.h"
|
||||
#include "builtins.h"
|
||||
|
||||
#define MAXHISTLOOPS 4 /* max recursions through fc */
|
||||
#define DEFEDITOR "ed" /* default editor *should* be $EDITOR */
|
||||
|
@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "mystring.h"
|
||||
#include "var.h"
|
||||
#include "builtins.h"
|
||||
|
||||
|
||||
static struct job *jobtab; /* array of jobs */
|
||||
@ -798,6 +800,7 @@ forkshell(struct job *jp, union node *n, int mode)
|
||||
handler = &main_handler;
|
||||
closescript();
|
||||
INTON;
|
||||
forcelocal = 0;
|
||||
clear_traps();
|
||||
#if JOBS
|
||||
jobctl = 0; /* do job control only in root shell */
|
||||
@ -1121,7 +1124,7 @@ backgndpidset(void)
|
||||
pid_t
|
||||
backgndpidval(void)
|
||||
{
|
||||
if (bgjob != NULL)
|
||||
if (bgjob != NULL && !forcelocal)
|
||||
bgjob->remembered = 1;
|
||||
return backgndpid;
|
||||
}
|
||||
|
@ -88,12 +88,7 @@ extern int in_dowait; /* are we in dowait()? */
|
||||
extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */
|
||||
|
||||
void setjobctl(int);
|
||||
int fgcmd(int, char **);
|
||||
int bgcmd(int, char **);
|
||||
int jobscmd(int, char **);
|
||||
void showjobs(int, int);
|
||||
int waitcmd(int, char **);
|
||||
int jobidcmd(int, char **);
|
||||
struct job *makejob(union node *, int);
|
||||
pid_t forkshell(struct job *, union node *, int);
|
||||
int waitforjob(struct job *, int *);
|
||||
|
@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "mystring.h"
|
||||
#include "exec.h"
|
||||
#include "cd.h"
|
||||
#include "builtins.h"
|
||||
|
||||
int rootpid;
|
||||
int rootshell;
|
||||
@ -150,7 +151,7 @@ main(int argc, char *argv[])
|
||||
state1:
|
||||
state = 2;
|
||||
if (privileged == 0)
|
||||
read_profile(".profile");
|
||||
read_profile("${HOME-}/.profile");
|
||||
else
|
||||
read_profile("/etc/suid_profile");
|
||||
}
|
||||
|
@ -39,5 +39,3 @@ extern struct jmploc main_handler; /* top level exception handler */
|
||||
|
||||
void readcmdfile(const char *);
|
||||
void cmdloop(int);
|
||||
int dotcmd(int, char **);
|
||||
int exitcmd(int, char **);
|
||||
|
@ -58,9 +58,7 @@ cat <<\!
|
||||
!
|
||||
awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \
|
||||
print $0}' builtins.def | sed 's/-[hj]//' > $temp
|
||||
awk '{ printf "int %s(int, char **);\n", $1}' $temp
|
||||
echo '
|
||||
int (*const builtinfunc[])(int, char **) = {'
|
||||
echo 'int (*const builtinfunc[])(int, char **) = {'
|
||||
awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp
|
||||
echo '};
|
||||
|
||||
@ -94,5 +92,7 @@ struct builtincmd {
|
||||
};
|
||||
|
||||
extern int (*const builtinfunc[])(int, char **);
|
||||
extern const struct builtincmd builtincmd[];'
|
||||
extern const struct builtincmd builtincmd[];
|
||||
'
|
||||
awk '{ printf "int %s(int, char **);\n", $1}' $temp
|
||||
rm -f $temp
|
||||
|
@ -39,8 +39,6 @@ extern int displayhist;
|
||||
void histedit(void);
|
||||
void sethistsize(const char *);
|
||||
void setterm(const char *);
|
||||
int histcmd(int, char **);
|
||||
int not_fcnumber(const char *);
|
||||
int str_to_event(const char *, int);
|
||||
int bindcmd(int, char **);
|
||||
|
||||
|
@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "memalloc.h"
|
||||
#include "error.h"
|
||||
#include "mystring.h"
|
||||
#include "builtins.h"
|
||||
#ifndef NO_HISTORY
|
||||
#include "myhistedit.h"
|
||||
#endif
|
||||
|
@ -108,8 +108,5 @@ void procargs(int, char **);
|
||||
void optschanged(void);
|
||||
void setparam(char **);
|
||||
void freeparam(struct shparam *);
|
||||
int shiftcmd(int, char **);
|
||||
int setcmd(int, char **);
|
||||
int getoptscmd(int, char **);
|
||||
int nextopt(const char *);
|
||||
void getoptsreset(const char *);
|
||||
|
17
bin/sh/sh.1
17
bin/sh/sh.1
@ -32,7 +32,7 @@
|
||||
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 10, 2011
|
||||
.Dd June 15, 2011
|
||||
.Dt SH 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -1536,10 +1536,7 @@ except that the built-in commands
|
||||
and
|
||||
.Ic trap
|
||||
return information about the main shell environment
|
||||
if they are the only command in a command substitution
|
||||
and the substitutions in the command cannot cause side effects
|
||||
(such as from assigning values to variables or referencing
|
||||
.Li $! ).
|
||||
if they are the only command in a command substitution.
|
||||
.Ss Arithmetic Expansion
|
||||
Arithmetic expansion provides a mechanism for evaluating an arithmetic
|
||||
expression and substituting its value.
|
||||
@ -1651,6 +1648,15 @@ matches a
|
||||
rather than introducing a character class.
|
||||
A character class matches any of the characters between the square brackets.
|
||||
A range of characters may be specified using a minus sign.
|
||||
A named class of characters (see
|
||||
.Xr wctype 3 )
|
||||
may be specified by surrounding the name with
|
||||
.Ql \&[:
|
||||
and
|
||||
.Ql :\&] .
|
||||
For example,
|
||||
.Ql \&[\&[:alpha:\&]\&]
|
||||
is a shell pattern that matches a single letter.
|
||||
The character class may be complemented by making an exclamation point
|
||||
.Pq Ql !\&
|
||||
the first character of the character class.
|
||||
@ -2575,6 +2581,7 @@ will return the argument.
|
||||
.Xr execve 2 ,
|
||||
.Xr getrlimit 2 ,
|
||||
.Xr umask 2 ,
|
||||
.Xr wctype 3 ,
|
||||
.Xr editrc 5
|
||||
.Sh HISTORY
|
||||
A
|
||||
|
@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "error.h"
|
||||
#include "trap.h"
|
||||
#include "mystring.h"
|
||||
#include "builtins.h"
|
||||
#include "myhistedit.h"
|
||||
|
||||
|
||||
|
@ -37,7 +37,6 @@ extern int pendingsigs;
|
||||
extern int in_dotrap;
|
||||
extern volatile sig_atomic_t gotwinch;
|
||||
|
||||
int trapcmd(int, char **);
|
||||
void clear_traps(void);
|
||||
int have_traps(void);
|
||||
void setsignal(int);
|
||||
|
11
bin/sh/var.c
11
bin/sh/var.c
@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include "error.h"
|
||||
#include "mystring.h"
|
||||
#include "parser.h"
|
||||
#include "builtins.h"
|
||||
#ifndef NO_HISTORY
|
||||
#include "myhistedit.h"
|
||||
#endif
|
||||
@ -94,6 +95,8 @@ struct var vps4;
|
||||
struct var vvers;
|
||||
static struct var voptind;
|
||||
|
||||
int forcelocal;
|
||||
|
||||
static const struct varinit varinit[] = {
|
||||
#ifndef NO_HISTORY
|
||||
{ &vhistsize, VUNSET, "HISTSIZE=",
|
||||
@ -325,6 +328,8 @@ setvareq(char *s, int flags)
|
||||
|
||||
if (aflag)
|
||||
flags |= VEXPORT;
|
||||
if (forcelocal && !(flags & (VNOSET | VNOLOCAL)))
|
||||
mklocal(s);
|
||||
vp = find_var(s, &vpp, &nlen);
|
||||
if (vp != NULL) {
|
||||
if (vp->flags & VREADONLY)
|
||||
@ -740,9 +745,9 @@ mklocal(char *name)
|
||||
vp = find_var(name, &vpp, NULL);
|
||||
if (vp == NULL) {
|
||||
if (strchr(name, '='))
|
||||
setvareq(savestr(name), VSTRFIXED);
|
||||
setvareq(savestr(name), VSTRFIXED | VNOLOCAL);
|
||||
else
|
||||
setvar(name, NULL, VSTRFIXED);
|
||||
setvar(name, NULL, VSTRFIXED | VNOLOCAL);
|
||||
vp = *vpp; /* the new variable */
|
||||
lvp->text = NULL;
|
||||
lvp->flags = VUNSET;
|
||||
@ -751,7 +756,7 @@ mklocal(char *name)
|
||||
lvp->flags = vp->flags;
|
||||
vp->flags |= VSTRFIXED|VTEXTFIXED;
|
||||
if (name[vp->name_len] == '=')
|
||||
setvareq(savestr(name), 0);
|
||||
setvareq(savestr(name), VNOLOCAL);
|
||||
}
|
||||
}
|
||||
lvp->vp = vp;
|
||||
|
@ -46,6 +46,7 @@
|
||||
#define VUNSET 0x20 /* the variable is not set */
|
||||
#define VNOFUNC 0x40 /* don't call the callback function */
|
||||
#define VNOSET 0x80 /* do not set variable - just readonly test */
|
||||
#define VNOLOCAL 0x100 /* ignore forcelocal */
|
||||
|
||||
|
||||
struct var {
|
||||
@ -68,6 +69,7 @@ struct localvar {
|
||||
|
||||
|
||||
struct localvar *localvars;
|
||||
extern int forcelocal;
|
||||
|
||||
extern struct var vifs;
|
||||
extern struct var vmail;
|
||||
@ -121,11 +123,7 @@ void updatecharset(void);
|
||||
void initcharset(void);
|
||||
char **environment(void);
|
||||
int showvarscmd(int, char **);
|
||||
int exportcmd(int, char **);
|
||||
int localcmd(int, char **);
|
||||
void mklocal(char *);
|
||||
void poplocalvars(void);
|
||||
int setvarcmd(int, char **);
|
||||
int unsetcmd(int, char **);
|
||||
int unsetvar(const char *);
|
||||
int setvarsafe(const char *, const char *, int);
|
||||
|
@ -27,7 +27,9 @@
|
||||
#include "target.h"
|
||||
#include "breakpoint.h"
|
||||
#include "value.h"
|
||||
#include "gdb_string.h"
|
||||
#include "osabi.h"
|
||||
#include "regset.h"
|
||||
|
||||
#include "ppc-tdep.h"
|
||||
#include "ppcfbsd-tdep.h"
|
||||
@ -80,6 +82,17 @@ ppcfbsd_supply_reg (char *regs, int regno)
|
||||
regcache_raw_supply (current_regcache, PC_REGNUM,
|
||||
regs + REG_PC_OFFSET);
|
||||
}
|
||||
static void
|
||||
ppcfbsd_supply_gregset (const struct regset *regset,
|
||||
struct regcache *regcache,
|
||||
int regnum, void *gregs, size_t size)
|
||||
{
|
||||
ppcfbsd_supply_reg (gregs, -1);
|
||||
}
|
||||
|
||||
static struct regset ppcfbsd_gregset = {
|
||||
NULL, (void*)ppcfbsd_supply_gregset
|
||||
};
|
||||
|
||||
void
|
||||
ppcfbsd_fill_reg (char *regs, int regno)
|
||||
@ -144,6 +157,20 @@ ppcfbsd_supply_fpreg (char *fpregs, int regno)
|
||||
fpregs + FPREG_FPSCR_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
ppcfbsd_supply_fpregset (const struct regset *regset,
|
||||
struct regcache * regcache,
|
||||
int regnum, void *fpset, size_t size)
|
||||
{
|
||||
ppcfbsd_supply_fpreg (fpset, -1);
|
||||
}
|
||||
|
||||
|
||||
static struct regset ppcfbsd_fpregset =
|
||||
{
|
||||
NULL, (void*)ppcfbsd_supply_fpregset
|
||||
};
|
||||
|
||||
void
|
||||
ppcfbsd_fill_fpreg (char *fpregs, int regno)
|
||||
{
|
||||
@ -174,69 +201,285 @@ ppcfbsd_fill_fpreg (char *fpregs, int regno)
|
||||
fpregs + FPREG_FPSCR_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
||||
CORE_ADDR ignore)
|
||||
/* Return the appropriate register set for the core section identified
|
||||
by SECT_NAME and SECT_SIZE. */
|
||||
|
||||
const struct regset *
|
||||
ppcfbsd_regset_from_core_section (struct gdbarch *gdbarch,
|
||||
const char *sect_name, size_t sect_size)
|
||||
{
|
||||
char *regs, *fpregs;
|
||||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
||||
|
||||
/* We get everything from one section. */
|
||||
if (which != 0)
|
||||
return;
|
||||
if (strcmp (sect_name, ".reg") == 0 && sect_size >= SIZEOF_STRUCT_REG)
|
||||
return &ppcfbsd_gregset;
|
||||
|
||||
regs = core_reg_sect;
|
||||
fpregs = core_reg_sect + SIZEOF_STRUCT_REG;
|
||||
if (strcmp (sect_name, ".reg2") == 0 && sect_size >= SIZEOF_STRUCT_FPREG)
|
||||
return &ppcfbsd_fpregset;
|
||||
|
||||
/* Integer registers. */
|
||||
ppcfbsd_supply_reg (regs, -1);
|
||||
|
||||
/* Floating point registers. */
|
||||
ppcfbsd_supply_fpreg (fpregs, -1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
||||
CORE_ADDR ignore)
|
||||
|
||||
/* Macros for matching instructions. Note that, since all the
|
||||
operands are masked off before they're or-ed into the instruction,
|
||||
you can use -1 to make masks. */
|
||||
|
||||
#define insn_d(opcd, rts, ra, d) \
|
||||
((((opcd) & 0x3f) << 26) \
|
||||
| (((rts) & 0x1f) << 21) \
|
||||
| (((ra) & 0x1f) << 16) \
|
||||
| ((d) & 0xffff))
|
||||
|
||||
#define insn_ds(opcd, rts, ra, d, xo) \
|
||||
((((opcd) & 0x3f) << 26) \
|
||||
| (((rts) & 0x1f) << 21) \
|
||||
| (((ra) & 0x1f) << 16) \
|
||||
| ((d) & 0xfffc) \
|
||||
| ((xo) & 0x3))
|
||||
|
||||
#define insn_xfx(opcd, rts, spr, xo) \
|
||||
((((opcd) & 0x3f) << 26) \
|
||||
| (((rts) & 0x1f) << 21) \
|
||||
| (((spr) & 0x1f) << 16) \
|
||||
| (((spr) & 0x3e0) << 6) \
|
||||
| (((xo) & 0x3ff) << 1))
|
||||
|
||||
/* Read a PPC instruction from memory. PPC instructions are always
|
||||
big-endian, no matter what endianness the program is running in, so
|
||||
we can't use read_memory_integer or one of its friends here. */
|
||||
static unsigned int
|
||||
read_insn (CORE_ADDR pc)
|
||||
{
|
||||
switch (which)
|
||||
unsigned char buf[4];
|
||||
|
||||
read_memory (pc, buf, 4);
|
||||
return (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
|
||||
}
|
||||
|
||||
|
||||
/* An instruction to match. */
|
||||
struct insn_pattern
|
||||
{
|
||||
unsigned int mask; /* mask the insn with this... */
|
||||
unsigned int data; /* ...and see if it matches this. */
|
||||
int optional; /* If non-zero, this insn may be absent. */
|
||||
};
|
||||
|
||||
/* Return non-zero if the instructions at PC match the series
|
||||
described in PATTERN, or zero otherwise. PATTERN is an array of
|
||||
'struct insn_pattern' objects, terminated by an entry whose mask is
|
||||
zero.
|
||||
|
||||
When the match is successful, fill INSN[i] with what PATTERN[i]
|
||||
matched. If PATTERN[i] is optional, and the instruction wasn't
|
||||
present, set INSN[i] to 0 (which is not a valid PPC instruction).
|
||||
INSN should have as many elements as PATTERN. Note that, if
|
||||
PATTERN contains optional instructions which aren't present in
|
||||
memory, then INSN will have holes, so INSN[i] isn't necessarily the
|
||||
i'th instruction in memory. */
|
||||
static int
|
||||
insns_match_pattern (CORE_ADDR pc,
|
||||
struct insn_pattern *pattern,
|
||||
unsigned int *insn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; pattern[i].mask; i++)
|
||||
{
|
||||
case 0: /* Integer registers. */
|
||||
if (core_reg_size != SIZEOF_STRUCT_REG)
|
||||
warning (_("Wrong size register set in core file."));
|
||||
insn[i] = read_insn (pc);
|
||||
if ((insn[i] & pattern[i].mask) == pattern[i].data)
|
||||
pc += 4;
|
||||
else if (pattern[i].optional)
|
||||
insn[i] = 0;
|
||||
else
|
||||
ppcfbsd_supply_reg (core_reg_sect, -1);
|
||||
break;
|
||||
|
||||
case 2: /* Floating point registers. */
|
||||
if (core_reg_size != SIZEOF_STRUCT_FPREG)
|
||||
warning (_("Wrong size FP register set in core file."));
|
||||
else
|
||||
ppcfbsd_supply_fpreg (core_reg_sect, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Don't know what kind of register request this is; just ignore it. */
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct core_fns ppcfbsd_core_fns =
|
||||
{
|
||||
bfd_target_unknown_flavour, /* core_flavour */
|
||||
default_check_format, /* check_format */
|
||||
default_core_sniffer, /* core_sniffer */
|
||||
fetch_core_registers, /* core_read_registers */
|
||||
NULL /* next */
|
||||
};
|
||||
|
||||
static struct core_fns ppcfbsd_elfcore_fns =
|
||||
/* Return the 'd' field of the d-form instruction INSN, properly
|
||||
sign-extended. */
|
||||
static CORE_ADDR
|
||||
insn_d_field (unsigned int insn)
|
||||
{
|
||||
bfd_target_elf_flavour, /* core_flavour */
|
||||
default_check_format, /* check_format */
|
||||
default_core_sniffer, /* core_sniffer */
|
||||
fetch_elfcore_registers, /* core_read_registers */
|
||||
NULL /* next */
|
||||
};
|
||||
return ((((CORE_ADDR) insn & 0xffff) ^ 0x8000) - 0x8000);
|
||||
}
|
||||
|
||||
|
||||
/* Return the 'ds' field of the ds-form instruction INSN, with the two
|
||||
zero bits concatenated at the right, and properly
|
||||
sign-extended. */
|
||||
static CORE_ADDR
|
||||
insn_ds_field (unsigned int insn)
|
||||
{
|
||||
return ((((CORE_ADDR) insn & 0xfffc) ^ 0x8000) - 0x8000);
|
||||
}
|
||||
|
||||
|
||||
/* If DESC is the address of a 64-bit PowerPC FreeBSD function
|
||||
descriptor, return the descriptor's entry point. */
|
||||
static CORE_ADDR
|
||||
ppc64_desc_entry_point (CORE_ADDR desc)
|
||||
{
|
||||
/* The first word of the descriptor is the entry point. */
|
||||
return (CORE_ADDR) read_memory_unsigned_integer (desc, 8);
|
||||
}
|
||||
|
||||
|
||||
/* Pattern for the standard linkage function. These are built by
|
||||
build_plt_stub in elf64-ppc.c, whose GLINK argument is always
|
||||
zero. */
|
||||
static struct insn_pattern ppc64_standard_linkage[] =
|
||||
{
|
||||
/* addis r12, r2, <any> */
|
||||
{ insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 },
|
||||
|
||||
/* std r2, 40(r1) */
|
||||
{ -1, insn_ds (62, 2, 1, 40, 0), 0 },
|
||||
|
||||
/* ld r11, <any>(r12) */
|
||||
{ insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 0 },
|
||||
|
||||
/* addis r12, r12, 1 <optional> */
|
||||
{ insn_d (-1, -1, -1, -1), insn_d (15, 12, 2, 1), 1 },
|
||||
|
||||
/* ld r2, <any>(r12) */
|
||||
{ insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 2, 12, 0, 0), 0 },
|
||||
|
||||
/* addis r12, r12, 1 <optional> */
|
||||
{ insn_d (-1, -1, -1, -1), insn_d (15, 12, 2, 1), 1 },
|
||||
|
||||
/* mtctr r11 */
|
||||
{ insn_xfx (-1, -1, -1, -1), insn_xfx (31, 11, 9, 467),
|
||||
0 },
|
||||
|
||||
/* ld r11, <any>(r12) */
|
||||
{ insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 11, 12, 0, 0), 0 },
|
||||
|
||||
/* bctr */
|
||||
{ -1, 0x4e800420, 0 },
|
||||
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
#define PPC64_STANDARD_LINKAGE_LEN \
|
||||
(sizeof (ppc64_standard_linkage) / sizeof (ppc64_standard_linkage[0]))
|
||||
|
||||
/* When the dynamic linker is doing lazy symbol resolution, the first
|
||||
call to a function in another object will go like this:
|
||||
|
||||
- The user's function calls the linkage function:
|
||||
|
||||
100007c4: 4b ff fc d5 bl 10000498
|
||||
100007c8: e8 41 00 28 ld r2,40(r1)
|
||||
|
||||
- The linkage function loads the entry point (and other stuff) from
|
||||
the function descriptor in the PLT, and jumps to it:
|
||||
|
||||
10000498: 3d 82 00 00 addis r12,r2,0
|
||||
1000049c: f8 41 00 28 std r2,40(r1)
|
||||
100004a0: e9 6c 80 98 ld r11,-32616(r12)
|
||||
100004a4: e8 4c 80 a0 ld r2,-32608(r12)
|
||||
100004a8: 7d 69 03 a6 mtctr r11
|
||||
100004ac: e9 6c 80 a8 ld r11,-32600(r12)
|
||||
100004b0: 4e 80 04 20 bctr
|
||||
|
||||
- But since this is the first time that PLT entry has been used, it
|
||||
sends control to its glink entry. That loads the number of the
|
||||
PLT entry and jumps to the common glink0 code:
|
||||
|
||||
10000c98: 38 00 00 00 li r0,0
|
||||
10000c9c: 4b ff ff dc b 10000c78
|
||||
|
||||
- The common glink0 code then transfers control to the dynamic
|
||||
linker's fixup code:
|
||||
|
||||
10000c78: e8 41 00 28 ld r2,40(r1)
|
||||
10000c7c: 3d 82 00 00 addis r12,r2,0
|
||||
10000c80: e9 6c 80 80 ld r11,-32640(r12)
|
||||
10000c84: e8 4c 80 88 ld r2,-32632(r12)
|
||||
10000c88: 7d 69 03 a6 mtctr r11
|
||||
10000c8c: e9 6c 80 90 ld r11,-32624(r12)
|
||||
10000c90: 4e 80 04 20 bctr
|
||||
|
||||
Eventually, this code will figure out how to skip all of this,
|
||||
including the dynamic linker. At the moment, we just get through
|
||||
the linkage function. */
|
||||
|
||||
/* If the current thread is about to execute a series of instructions
|
||||
at PC matching the ppc64_standard_linkage pattern, and INSN is the result
|
||||
from that pattern match, return the code address to which the
|
||||
standard linkage function will send them. (This doesn't deal with
|
||||
dynamic linker lazy symbol resolution stubs.) */
|
||||
static CORE_ADDR
|
||||
ppc64_standard_linkage_target (CORE_ADDR pc, unsigned int *insn)
|
||||
{
|
||||
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
|
||||
|
||||
/* The address of the function descriptor this linkage function
|
||||
references. */
|
||||
CORE_ADDR desc
|
||||
= ((CORE_ADDR) read_register (tdep->ppc_gp0_regnum + 2)
|
||||
+ (insn_d_field (insn[0]) << 16)
|
||||
+ insn_ds_field (insn[2]));
|
||||
|
||||
/* The first word of the descriptor is the entry point. Return that. */
|
||||
return ppc64_desc_entry_point (desc);
|
||||
}
|
||||
|
||||
|
||||
/* Given that we've begun executing a call trampoline at PC, return
|
||||
the entry point of the function the trampoline will go to. */
|
||||
static CORE_ADDR
|
||||
ppc64_skip_trampoline_code (CORE_ADDR pc)
|
||||
{
|
||||
unsigned int ppc64_standard_linkage_insn[PPC64_STANDARD_LINKAGE_LEN];
|
||||
|
||||
if (insns_match_pattern (pc, ppc64_standard_linkage,
|
||||
ppc64_standard_linkage_insn))
|
||||
return ppc64_standard_linkage_target (pc, ppc64_standard_linkage_insn);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Support for CONVERT_FROM_FUNC_PTR_ADDR (ARCH, ADDR, TARG) on PPC64
|
||||
GNU/Linux and FreeBSD.
|
||||
|
||||
Usually a function pointer's representation is simply the address
|
||||
of the function. On GNU/Linux on the 64-bit PowerPC however, a
|
||||
function pointer is represented by a pointer to a TOC entry. This
|
||||
TOC entry contains three words, the first word is the address of
|
||||
the function, the second word is the TOC pointer (r2), and the
|
||||
third word is the static chain value. Throughout GDB it is
|
||||
currently assumed that a function pointer contains the address of
|
||||
the function, which is not easy to fix. In addition, the
|
||||
conversion of a function address to a function pointer would
|
||||
require allocation of a TOC entry in the inferior's memory space,
|
||||
with all its drawbacks. To be able to call C++ virtual methods in
|
||||
the inferior (which are called via function pointers),
|
||||
find_function_addr uses this function to get the function address
|
||||
from a function pointer. */
|
||||
|
||||
/* If ADDR points at what is clearly a function descriptor, transform
|
||||
it into the address of the corresponding function. Be
|
||||
conservative, otherwize GDB will do the transformation on any
|
||||
random addresses such as occures when there is no symbol table. */
|
||||
|
||||
static CORE_ADDR
|
||||
ppc64_fbsd_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
|
||||
CORE_ADDR addr,
|
||||
struct target_ops *targ)
|
||||
{
|
||||
struct section_table *s = target_section_by_addr (targ, addr);
|
||||
|
||||
/* Check if ADDR points to a function descriptor. */
|
||||
if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
|
||||
return get_target_memory_unsigned (targ, addr, 8);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
static int
|
||||
ppcfbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
|
||||
@ -270,27 +513,42 @@ static void
|
||||
ppcfbsd_init_abi (struct gdbarch_info info,
|
||||
struct gdbarch *gdbarch)
|
||||
{
|
||||
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
||||
|
||||
/* FreeBSD doesn't support the 128-bit `long double' from the psABI. */
|
||||
set_gdbarch_long_double_bit (gdbarch, 64);
|
||||
|
||||
set_gdbarch_pc_in_sigtramp (gdbarch, ppcfbsd_pc_in_sigtramp);
|
||||
/* For NetBSD, this is an on again, off again thing. Some systems
|
||||
do use the broken struct convention, and some don't. */
|
||||
set_gdbarch_return_value (gdbarch, ppcfbsd_return_value);
|
||||
#ifdef __powerpc64__
|
||||
set_solib_svr4_fetch_link_map_offsets (gdbarch,
|
||||
svr4_lp64_fetch_link_map_offsets);
|
||||
#else
|
||||
set_solib_svr4_fetch_link_map_offsets (gdbarch,
|
||||
svr4_ilp32_fetch_link_map_offsets);
|
||||
#endif
|
||||
|
||||
if (tdep->wordsize == 4)
|
||||
{
|
||||
set_gdbarch_return_value (gdbarch, ppcfbsd_return_value);
|
||||
set_solib_svr4_fetch_link_map_offsets (gdbarch,
|
||||
svr4_ilp32_fetch_link_map_offsets);
|
||||
}
|
||||
|
||||
if (tdep->wordsize == 8)
|
||||
{
|
||||
set_gdbarch_convert_from_func_ptr_addr
|
||||
(gdbarch, ppc64_fbsd_convert_from_func_ptr_addr);
|
||||
|
||||
set_gdbarch_skip_trampoline_code (gdbarch, ppc64_skip_trampoline_code);
|
||||
|
||||
set_solib_svr4_fetch_link_map_offsets (gdbarch,
|
||||
svr4_lp64_fetch_link_map_offsets);
|
||||
}
|
||||
|
||||
set_gdbarch_regset_from_core_section (gdbarch,
|
||||
ppcfbsd_regset_from_core_section);
|
||||
}
|
||||
|
||||
void
|
||||
_initialize_ppcfbsd_tdep (void)
|
||||
{
|
||||
gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc,
|
||||
GDB_OSABI_FREEBSD_ELF, ppcfbsd_init_abi);
|
||||
gdbarch_register_osabi (bfd_arch_powerpc, bfd_mach_ppc64,
|
||||
GDB_OSABI_FREEBSD_ELF, ppcfbsd_init_abi);
|
||||
gdbarch_register_osabi (bfd_arch_rs6000, 0, GDB_OSABI_FREEBSD_ELF,
|
||||
ppcfbsd_init_abi);
|
||||
gdbarch_register_osabi (bfd_arch_powerpc, 0, GDB_OSABI_FREEBSD_ELF,
|
||||
ppcfbsd_init_abi);
|
||||
|
||||
add_core_fns (&ppcfbsd_core_fns);
|
||||
add_core_fns (&ppcfbsd_elfcore_fns);
|
||||
}
|
||||
|
@ -282,6 +282,8 @@ typedef enum {
|
||||
LLVMRealPredicateTrue /**< Always true (always folded) */
|
||||
} LLVMRealPredicate;
|
||||
|
||||
void LLVMInitializeCore(LLVMPassRegistryRef R);
|
||||
|
||||
|
||||
/*===-- Error handling ----------------------------------------------------===*/
|
||||
|
||||
@ -1164,6 +1166,7 @@ namespace llvm {
|
||||
for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
|
||||
cast<T>(*I);
|
||||
#endif
|
||||
(void)Length;
|
||||
return reinterpret_cast<T**>(Vals);
|
||||
}
|
||||
|
||||
|
@ -7,16 +7,16 @@
|
||||
|* *|
|
||||
|*===----------------------------------------------------------------------===*|
|
||||
|* *|
|
||||
|* This header provides public interface to a disassembler library. *|
|
||||
|* This header provides a public interface to a disassembler library. *|
|
||||
|* LLVM provides an implementation of this interface. *|
|
||||
|* *|
|
||||
\*===----------------------------------------------------------------------===*/
|
||||
|
||||
#ifndef LLVM_C_DISASSEMBLER_H
|
||||
#define LLVM_C_DISASSEMBLER_H 1
|
||||
#define LLVM_C_DISASSEMBLER_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* An opaque reference to a disassembler context.
|
||||
@ -38,14 +38,11 @@ typedef void *LLVMDisasmContextRef;
|
||||
* will be the instruction width. The information is returned in TagBuf and is
|
||||
* Triple specific with its specific information defined by the value of
|
||||
* TagType for that Triple. If symbolic information is returned the function
|
||||
* returns 1 else it returns 0.
|
||||
* returns 1, otherwise it returns 0.
|
||||
*/
|
||||
typedef int (*LLVMOpInfoCallback)(void *DisInfo,
|
||||
uint64_t PC,
|
||||
uint64_t Offset,
|
||||
uint64_t Size,
|
||||
int TagType,
|
||||
void *TagBuf);
|
||||
typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC,
|
||||
uint64_t Offset, uint64_t Size,
|
||||
int TagType, void *TagBuf);
|
||||
|
||||
/**
|
||||
* The initial support in LLVM MC for the most general form of a relocatable
|
||||
@ -68,10 +65,11 @@ typedef int (*LLVMOpInfoCallback)(void *DisInfo,
|
||||
* operands like "_foo@GOT", ":lower16:_foo", etc.
|
||||
*/
|
||||
struct LLVMOpInfoSymbol1 {
|
||||
uint64_t Present; /* 1 if this symbol is present */
|
||||
char *Name; /* symbol name if not NULL */
|
||||
uint64_t Value; /* symbol value if name is NULL */
|
||||
uint64_t Present; /* 1 if this symbol is present */
|
||||
char *Name; /* symbol name if not NULL */
|
||||
uint64_t Value; /* symbol value if name is NULL */
|
||||
};
|
||||
|
||||
struct LLVMOpInfo1 {
|
||||
struct LLVMOpInfoSymbol1 AddSymbol;
|
||||
struct LLVMOpInfoSymbol1 SubtractSymbol;
|
||||
@ -92,11 +90,11 @@ struct LLVMOpInfo1 {
|
||||
|
||||
/**
|
||||
* The type for the symbol lookup function. This may be called by the
|
||||
* disassembler for such things like adding a comment for a PC plus a constant
|
||||
* disassembler for things like adding a comment for a PC plus a constant
|
||||
* offset load instruction to use a symbol name instead of a load address value.
|
||||
* It is passed the block information is saved when the disassembler context is
|
||||
* created and a value of a symbol to look up. If no symbol is found NULL is
|
||||
* to be returned.
|
||||
* returned.
|
||||
*/
|
||||
typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
|
||||
uint64_t SymbolValue);
|
||||
@ -107,40 +105,33 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* Create a disassembler for the TripleName. Symbolic disassembly is supported
|
||||
* by passing a block of information in the DisInfo parameter and specifing the
|
||||
* TagType and call back functions as described above. These can all be passed
|
||||
* as NULL. If successful this returns a disassembler context if not it
|
||||
* by passing a block of information in the DisInfo parameter and specifying the
|
||||
* TagType and callback functions as described above. These can all be passed
|
||||
* as NULL. If successful, this returns a disassembler context. If not, it
|
||||
* returns NULL.
|
||||
*/
|
||||
extern LLVMDisasmContextRef
|
||||
LLVMCreateDisasm(const char *TripleName,
|
||||
void *DisInfo,
|
||||
int TagType,
|
||||
LLVMOpInfoCallback GetOpInfo,
|
||||
LLVMSymbolLookupCallback SymbolLookUp);
|
||||
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||
int TagType, LLVMOpInfoCallback GetOpInfo,
|
||||
LLVMSymbolLookupCallback SymbolLookUp);
|
||||
|
||||
/**
|
||||
* Dispose of a disassembler context.
|
||||
*/
|
||||
extern void
|
||||
LLVMDisasmDispose(LLVMDisasmContextRef DC);
|
||||
void LLVMDisasmDispose(LLVMDisasmContextRef DC);
|
||||
|
||||
/**
|
||||
* Disassmble a single instruction using the disassembler context specified in
|
||||
* the parameter DC. The bytes of the instruction are specified in the parameter
|
||||
* Bytes, and contains at least BytesSize number of bytes. The instruction is
|
||||
* at the address specified by the PC parameter. If a valid instruction can be
|
||||
* disassembled its string is returned indirectly in OutString which whos size
|
||||
* is specified in the parameter OutStringSize. This function returns the
|
||||
* number of bytes in the instruction or zero if there was no valid instruction.
|
||||
* Disassemble a single instruction using the disassembler context specified in
|
||||
* the parameter DC. The bytes of the instruction are specified in the
|
||||
* parameter Bytes, and contains at least BytesSize number of bytes. The
|
||||
* instruction is at the address specified by the PC parameter. If a valid
|
||||
* instruction can be disassembled, its string is returned indirectly in
|
||||
* OutString whose size is specified in the parameter OutStringSize. This
|
||||
* function returns the number of bytes in the instruction or zero if there was
|
||||
* no valid instruction.
|
||||
*/
|
||||
extern size_t
|
||||
LLVMDisasmInstruction(LLVMDisasmContextRef DC,
|
||||
uint8_t *Bytes,
|
||||
uint64_t BytesSize,
|
||||
uint64_t PC,
|
||||
char *OutString,
|
||||
size_t OutStringSize);
|
||||
size_t LLVMDisasmInstruction(LLVMDisasmContextRef DC, uint8_t *Bytes,
|
||||
uint64_t BytesSize, uint64_t PC,
|
||||
char *OutString, size_t OutStringSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -671,17 +671,10 @@ class FastFoldingSetNode : public FoldingSetNode {
|
||||
// Partial specializations of FoldingSetTrait.
|
||||
|
||||
template<typename T> struct FoldingSetTrait<T*> {
|
||||
static inline void Profile(const T *X, FoldingSetNodeID &ID) {
|
||||
static inline void Profile(T *X, FoldingSetNodeID &ID) {
|
||||
ID.AddPointer(X);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct FoldingSetTrait<const T*> {
|
||||
static inline void Profile(const T *X, FoldingSetNodeID &ID) {
|
||||
ID.AddPointer(X);
|
||||
}
|
||||
};
|
||||
|
||||
} // End of namespace llvm.
|
||||
|
||||
#endif
|
||||
|
158
contrib/llvm/include/llvm/ADT/PackedVector.h
Normal file
158
contrib/llvm/include/llvm/ADT/PackedVector.h
Normal file
@ -0,0 +1,158 @@
|
||||
//===- llvm/ADT/PackedVector.h - Packed values vector -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the PackedVector class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_ADT_PACKEDVECTOR_H
|
||||
#define LLVM_ADT_PACKEDVECTOR_H
|
||||
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include <limits>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template <typename T, unsigned BitNum, bool isSigned>
|
||||
class PackedVectorBase;
|
||||
|
||||
// This won't be necessary if we can specialize members without specializing
|
||||
// the parent template.
|
||||
template <typename T, unsigned BitNum>
|
||||
class PackedVectorBase<T, BitNum, false> {
|
||||
protected:
|
||||
static T getValue(const llvm::BitVector &Bits, unsigned Idx) {
|
||||
T val = T();
|
||||
for (unsigned i = 0; i != BitNum; ++i)
|
||||
val = T(val | ((Bits[(Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i));
|
||||
return val;
|
||||
}
|
||||
|
||||
static void setValue(llvm::BitVector &Bits, unsigned Idx, T val) {
|
||||
assert((val >> BitNum) == 0 && "value is too big");
|
||||
for (unsigned i = 0; i != BitNum; ++i)
|
||||
Bits[(Idx << (BitNum-1)) + i] = val & (T(1) << i);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, unsigned BitNum>
|
||||
class PackedVectorBase<T, BitNum, true> {
|
||||
protected:
|
||||
static T getValue(const llvm::BitVector &Bits, unsigned Idx) {
|
||||
T val = T();
|
||||
for (unsigned i = 0; i != BitNum-1; ++i)
|
||||
val = T(val | ((Bits[(Idx << (BitNum-1)) + i] ? 1UL : 0UL) << i));
|
||||
if (Bits[(Idx << (BitNum-1)) + BitNum-1])
|
||||
val = ~val;
|
||||
return val;
|
||||
}
|
||||
|
||||
static void setValue(llvm::BitVector &Bits, unsigned Idx, T val) {
|
||||
if (val < 0) {
|
||||
val = ~val;
|
||||
Bits.set((Idx << (BitNum-1)) + BitNum-1);
|
||||
}
|
||||
assert((val >> (BitNum-1)) == 0 && "value is too big");
|
||||
for (unsigned i = 0; i != BitNum-1; ++i)
|
||||
Bits[(Idx << (BitNum-1)) + i] = val & (T(1) << i);
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Store a vector of values using a specific number of bits for each
|
||||
/// value. Both signed and unsigned types can be used, e.g
|
||||
/// @code
|
||||
/// PackedVector<signed, 2> vec;
|
||||
/// @endcode
|
||||
/// will create a vector accepting values -2, -1, 0, 1. Any other value will hit
|
||||
/// an assertion.
|
||||
template <typename T, unsigned BitNum>
|
||||
class PackedVector : public PackedVectorBase<T, BitNum,
|
||||
std::numeric_limits<T>::is_signed> {
|
||||
llvm::BitVector Bits;
|
||||
typedef PackedVectorBase<T, BitNum, std::numeric_limits<T>::is_signed> base;
|
||||
|
||||
public:
|
||||
class reference {
|
||||
PackedVector &Vec;
|
||||
const unsigned Idx;
|
||||
|
||||
reference(); // Undefined
|
||||
public:
|
||||
reference(PackedVector &vec, unsigned idx) : Vec(vec), Idx(idx) { }
|
||||
|
||||
reference &operator=(T val) {
|
||||
Vec.setValue(Vec.Bits, Idx, val);
|
||||
return *this;
|
||||
}
|
||||
operator T() {
|
||||
return Vec.getValue(Vec.Bits, Idx);
|
||||
}
|
||||
};
|
||||
|
||||
PackedVector() { }
|
||||
explicit PackedVector(unsigned size) : Bits(size << (BitNum-1)) { }
|
||||
|
||||
bool empty() const { return Bits.empty(); }
|
||||
|
||||
unsigned size() const { return Bits.size() >> (BitNum-1); }
|
||||
|
||||
void clear() { Bits.clear(); }
|
||||
|
||||
void resize(unsigned N) { Bits.resize(N << (BitNum-1)); }
|
||||
|
||||
void reserve(unsigned N) { Bits.reserve(N << (BitNum-1)); }
|
||||
|
||||
PackedVector &reset() {
|
||||
Bits.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void push_back(T val) {
|
||||
resize(size()+1);
|
||||
(*this)[size()-1] = val;
|
||||
}
|
||||
|
||||
reference operator[](unsigned Idx) {
|
||||
return reference(*this, Idx);
|
||||
}
|
||||
|
||||
T operator[](unsigned Idx) const {
|
||||
return base::getValue(Bits, Idx);
|
||||
}
|
||||
|
||||
bool operator==(const PackedVector &RHS) const {
|
||||
return Bits == RHS.Bits;
|
||||
}
|
||||
|
||||
bool operator!=(const PackedVector &RHS) const {
|
||||
return Bits != RHS.Bits;
|
||||
}
|
||||
|
||||
const PackedVector &operator=(const PackedVector &RHS) {
|
||||
Bits = RHS.Bits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PackedVector &operator|=(const PackedVector &RHS) {
|
||||
Bits |= RHS.Bits;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(PackedVector &RHS) {
|
||||
Bits.swap(RHS.Bits);
|
||||
}
|
||||
};
|
||||
|
||||
// Leave BitNum=0 undefined.
|
||||
template <typename T>
|
||||
class PackedVector<T, 0>;
|
||||
|
||||
} // end llvm namespace
|
||||
|
||||
#endif
|
@ -46,7 +46,14 @@ namespace llvm {
|
||||
// integer works around this bug.
|
||||
static size_t min(size_t a, size_t b) { return a < b ? a : b; }
|
||||
static size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
||||
|
||||
|
||||
// Workaround memcmp issue with null pointers (undefined behavior)
|
||||
// by providing a specialized version
|
||||
static int compareMemory(const char *Lhs, const char *Rhs, size_t Length) {
|
||||
if (Length == 0) { return 0; }
|
||||
return ::memcmp(Lhs,Rhs,Length);
|
||||
}
|
||||
|
||||
public:
|
||||
/// @name Constructors
|
||||
/// @{
|
||||
@ -56,11 +63,17 @@ namespace llvm {
|
||||
|
||||
/// Construct a string ref from a cstring.
|
||||
/*implicit*/ StringRef(const char *Str)
|
||||
: Data(Str), Length(::strlen(Str)) {}
|
||||
: Data(Str) {
|
||||
assert(Str && "StringRef cannot be built from a NULL argument");
|
||||
Length = ::strlen(Str); // invoking strlen(NULL) is undefined behavior
|
||||
}
|
||||
|
||||
/// Construct a string ref from a pointer and length.
|
||||
/*implicit*/ StringRef(const char *data, size_t length)
|
||||
: Data(data), Length(length) {}
|
||||
: Data(data), Length(length) {
|
||||
assert((data || length == 0) &&
|
||||
"StringRef cannot be built from a NULL argument with non-null length");
|
||||
}
|
||||
|
||||
/// Construct a string ref from an std::string.
|
||||
/*implicit*/ StringRef(const std::string &Str)
|
||||
@ -104,7 +117,7 @@ namespace llvm {
|
||||
/// compare() when the relative ordering of inequal strings isn't needed.
|
||||
bool equals(StringRef RHS) const {
|
||||
return (Length == RHS.Length &&
|
||||
memcmp(Data, RHS.Data, RHS.Length) == 0);
|
||||
compareMemory(Data, RHS.Data, RHS.Length) == 0);
|
||||
}
|
||||
|
||||
/// equals_lower - Check for string equality, ignoring case.
|
||||
@ -116,7 +129,7 @@ namespace llvm {
|
||||
/// is lexicographically less than, equal to, or greater than the \arg RHS.
|
||||
int compare(StringRef RHS) const {
|
||||
// Check the prefix for a mismatch.
|
||||
if (int Res = memcmp(Data, RHS.Data, min(Length, RHS.Length)))
|
||||
if (int Res = compareMemory(Data, RHS.Data, min(Length, RHS.Length)))
|
||||
return Res < 0 ? -1 : 1;
|
||||
|
||||
// Otherwise the prefixes match, so we only need to check the lengths.
|
||||
@ -183,13 +196,13 @@ namespace llvm {
|
||||
/// startswith - Check if this string starts with the given \arg Prefix.
|
||||
bool startswith(StringRef Prefix) const {
|
||||
return Length >= Prefix.Length &&
|
||||
memcmp(Data, Prefix.Data, Prefix.Length) == 0;
|
||||
compareMemory(Data, Prefix.Data, Prefix.Length) == 0;
|
||||
}
|
||||
|
||||
/// endswith - Check if this string ends with the given \arg Suffix.
|
||||
bool endswith(StringRef Suffix) const {
|
||||
return Length >= Suffix.Length &&
|
||||
memcmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
|
||||
compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -447,6 +460,10 @@ namespace llvm {
|
||||
return LHS.compare(RHS) != -1;
|
||||
}
|
||||
|
||||
inline std::string &operator+=(std::string &buffer, llvm::StringRef string) {
|
||||
return buffer.append(string.data(), string.size());
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
// StringRefs can be treated like a POD type.
|
||||
|
@ -225,7 +225,7 @@ class Triple {
|
||||
/// if the environment component is present).
|
||||
StringRef getOSAndEnvironmentName() const;
|
||||
|
||||
/// getOSNumber - Parse the version number from the OS name component of the
|
||||
/// getOSVersion - Parse the version number from the OS name component of the
|
||||
/// triple, if present.
|
||||
///
|
||||
/// For example, "fooos1.2.3" would return (1, 2, 3).
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define LLVM_ANALYSIS_ALIAS_ANALYSIS_H
|
||||
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -488,6 +489,32 @@ class AliasAnalysis {
|
||||
}
|
||||
};
|
||||
|
||||
// Specialize DenseMapInfo for Location.
|
||||
template<>
|
||||
struct DenseMapInfo<AliasAnalysis::Location> {
|
||||
static inline AliasAnalysis::Location getEmptyKey() {
|
||||
return
|
||||
AliasAnalysis::Location(DenseMapInfo<const Value *>::getEmptyKey(),
|
||||
0, 0);
|
||||
}
|
||||
static inline AliasAnalysis::Location getTombstoneKey() {
|
||||
return
|
||||
AliasAnalysis::Location(DenseMapInfo<const Value *>::getTombstoneKey(),
|
||||
0, 0);
|
||||
}
|
||||
static unsigned getHashValue(const AliasAnalysis::Location &Val) {
|
||||
return DenseMapInfo<const Value *>::getHashValue(Val.Ptr) ^
|
||||
DenseMapInfo<uint64_t>::getHashValue(Val.Size) ^
|
||||
DenseMapInfo<const MDNode *>::getHashValue(Val.TBAATag);
|
||||
}
|
||||
static bool isEqual(const AliasAnalysis::Location &LHS,
|
||||
const AliasAnalysis::Location &RHS) {
|
||||
return LHS.Ptr == RHS.Ptr &&
|
||||
LHS.Size == RHS.Size &&
|
||||
LHS.TBAATag == RHS.TBAATag;
|
||||
}
|
||||
};
|
||||
|
||||
/// isNoAliasCall - Return true if this pointer is returned by a noalias
|
||||
/// function.
|
||||
bool isNoAliasCall(const Value *V);
|
||||
|
78
contrib/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
Normal file
78
contrib/llvm/include/llvm/Analysis/BranchProbabilityInfo.h
Normal file
@ -0,0 +1,78 @@
|
||||
//===--- BranchProbabilityInfo.h - Branch Probability Analysis --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This pass is used to evaluate branch probabilties.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_ANALYSIS_BRANCHPROBABILITYINFO_H
|
||||
#define LLVM_ANALYSIS_BRANCHPROBABILITYINFO_H
|
||||
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Support/BranchProbability.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class raw_ostream;
|
||||
|
||||
class BranchProbabilityInfo : public FunctionPass {
|
||||
|
||||
// Default weight value. Used when we don't have information about the edge.
|
||||
static const uint32_t DEFAULT_WEIGHT = 16;
|
||||
|
||||
typedef std::pair<BasicBlock *, BasicBlock *> Edge;
|
||||
|
||||
DenseMap<Edge, uint32_t> Weights;
|
||||
|
||||
// Get sum of the block successors' weights.
|
||||
uint32_t getSumForBlock(BasicBlock *BB) const;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
|
||||
BranchProbabilityInfo() : FunctionPass(ID) {
|
||||
initializeBranchProbabilityInfoPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<LoopInfo>();
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F);
|
||||
|
||||
// Returned value is between 1 and UINT32_MAX. Look at
|
||||
// BranchProbabilityInfo.cpp for details.
|
||||
uint32_t getEdgeWeight(BasicBlock *Src, BasicBlock *Dst) const;
|
||||
|
||||
// Look at BranchProbabilityInfo.cpp for details. Use it with caution!
|
||||
void setEdgeWeight(BasicBlock *Src, BasicBlock *Dst, uint32_t Weight);
|
||||
|
||||
// A 'Hot' edge is an edge which probability is >= 80%.
|
||||
bool isEdgeHot(BasicBlock *Src, BasicBlock *Dst) const;
|
||||
|
||||
// Return a hot successor for the block BB or null if there isn't one.
|
||||
BasicBlock *getHotSucc(BasicBlock *BB) const;
|
||||
|
||||
// Return a probability as a fraction between 0 (0% probability) and
|
||||
// 1 (100% probability), however the value is never equal to 0, and can be 1
|
||||
// only iff SRC block has only one successor.
|
||||
BranchProbability getEdgeProbability(BasicBlock *Src, BasicBlock *Dst) const;
|
||||
|
||||
// Print value between 0 (0% probability) and 1 (100% probability),
|
||||
// however the value is never equal to 0, and can be 1 only iff SRC block
|
||||
// has only one successor.
|
||||
raw_ostream &printEdgeProbability(raw_ostream &OS, BasicBlock *Src,
|
||||
BasicBlock *Dst) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -259,6 +259,9 @@ class CallGraphNode {
|
||||
/// addCalledFunction - Add a function to the list of functions called by this
|
||||
/// one.
|
||||
void addCalledFunction(CallSite CS, CallGraphNode *M) {
|
||||
assert(!CS.getInstruction() ||
|
||||
!CS.getCalledFunction() ||
|
||||
!CS.getCalledFunction()->isIntrinsic());
|
||||
CalledFunctions.push_back(std::make_pair(CS.getInstruction(), M));
|
||||
M->AddRef();
|
||||
}
|
||||
|
@ -117,8 +117,9 @@ namespace llvm {
|
||||
/// @param Name Typedef name.
|
||||
/// @param File File where this type is defined.
|
||||
/// @param LineNo Line number.
|
||||
/// @param Context The surrounding context for the typedef.
|
||||
DIType createTypedef(DIType Ty, StringRef Name, DIFile File,
|
||||
unsigned LineNo);
|
||||
unsigned LineNo, DIDescriptor Context);
|
||||
|
||||
/// createFriend - Create debugging information entry for a 'friend'.
|
||||
DIType createFriend(DIType Ty, DIType FriendTy);
|
||||
|
@ -49,15 +49,16 @@ namespace llvm {
|
||||
class DIDescriptor {
|
||||
public:
|
||||
enum {
|
||||
FlagPrivate = 1 << 0,
|
||||
FlagProtected = 1 << 1,
|
||||
FlagFwdDecl = 1 << 2,
|
||||
FlagAppleBlock = 1 << 3,
|
||||
FlagBlockByrefStruct = 1 << 4,
|
||||
FlagVirtual = 1 << 5,
|
||||
FlagArtificial = 1 << 6,
|
||||
FlagExplicit = 1 << 7,
|
||||
FlagPrototyped = 1 << 8
|
||||
FlagPrivate = 1 << 0,
|
||||
FlagProtected = 1 << 1,
|
||||
FlagFwdDecl = 1 << 2,
|
||||
FlagAppleBlock = 1 << 3,
|
||||
FlagBlockByrefStruct = 1 << 4,
|
||||
FlagVirtual = 1 << 5,
|
||||
FlagArtificial = 1 << 6,
|
||||
FlagExplicit = 1 << 7,
|
||||
FlagPrototyped = 1 << 8,
|
||||
FlagObjcClassComplete = 1 << 9
|
||||
};
|
||||
protected:
|
||||
const MDNode *DbgNode;
|
||||
@ -271,6 +272,9 @@ namespace llvm {
|
||||
bool isArtificial() const {
|
||||
return (getFlags() & FlagArtificial) != 0;
|
||||
}
|
||||
bool isObjcClassComplete() const {
|
||||
return (getFlags() & FlagObjcClassComplete) != 0;
|
||||
}
|
||||
bool isValid() const {
|
||||
return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
|
||||
}
|
||||
|
@ -14,8 +14,8 @@
|
||||
#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
|
||||
#define LLVM_ANALYSIS_FINDUSEDTYPES_H
|
||||
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -23,7 +23,7 @@ class Type;
|
||||
class Value;
|
||||
|
||||
class FindUsedTypes : public ModulePass {
|
||||
std::set<const Type *> UsedTypes;
|
||||
SetVector<const Type *> UsedTypes;
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
FindUsedTypes() : ModulePass(ID) {
|
||||
@ -33,7 +33,7 @@ class FindUsedTypes : public ModulePass {
|
||||
/// getTypes - After the pass has been run, return the set containing all of
|
||||
/// the types used in the module.
|
||||
///
|
||||
const std::set<const Type *> &getTypes() const { return UsedTypes; }
|
||||
const SetVector<const Type *> &getTypes() const { return UsedTypes; }
|
||||
|
||||
/// Print the types found in the module. If the optional Module parameter is
|
||||
/// passed in, then the types are printed symbolically if possible, using the
|
||||
|
@ -37,8 +37,8 @@ class TargetData;
|
||||
class IVStrideUse : public CallbackVH, public ilist_node<IVStrideUse> {
|
||||
friend class IVUsers;
|
||||
public:
|
||||
IVStrideUse(IVUsers *P, Instruction* U, Value *O)
|
||||
: CallbackVH(U), Parent(P), OperandValToReplace(O) {
|
||||
IVStrideUse(IVUsers *P, Instruction* U, Value *O, Value *PN)
|
||||
: CallbackVH(U), Parent(P), OperandValToReplace(O), Phi(PN) {
|
||||
}
|
||||
|
||||
/// getUser - Return the user instruction for this use.
|
||||
@ -51,6 +51,11 @@ class IVStrideUse : public CallbackVH, public ilist_node<IVStrideUse> {
|
||||
setValPtr(NewUser);
|
||||
}
|
||||
|
||||
/// getPhi - Return the phi node that represents this IV.
|
||||
PHINode *getPhi() const {
|
||||
return cast<PHINode>(Phi);
|
||||
}
|
||||
|
||||
/// getOperandValToReplace - Return the Value of the operand in the user
|
||||
/// instruction that this IVStrideUse is representing.
|
||||
Value *getOperandValToReplace() const {
|
||||
@ -81,6 +86,9 @@ class IVStrideUse : public CallbackVH, public ilist_node<IVStrideUse> {
|
||||
/// that this IVStrideUse is representing.
|
||||
WeakVH OperandValToReplace;
|
||||
|
||||
/// Phi - The loop header phi that represents this IV.
|
||||
WeakVH Phi;
|
||||
|
||||
/// PostIncLoops - The set of loops for which Expr has been adjusted to
|
||||
/// use post-inc mode. This corresponds with SCEVExpander's post-inc concept.
|
||||
PostIncLoopSet PostIncLoops;
|
||||
@ -143,9 +151,9 @@ class IVUsers : public LoopPass {
|
||||
/// AddUsersIfInteresting - Inspect the specified Instruction. If it is a
|
||||
/// reducible SCEV, recursively add its users to the IVUsesByStride set and
|
||||
/// return true. Otherwise, return false.
|
||||
bool AddUsersIfInteresting(Instruction *I);
|
||||
bool AddUsersIfInteresting(Instruction *I, PHINode *Phi);
|
||||
|
||||
IVStrideUse &AddUser(Instruction *User, Value *Operand);
|
||||
IVStrideUse &AddUser(Instruction *User, Value *Operand, PHINode *Phi);
|
||||
|
||||
/// getReplacementExpr - Return a SCEV expression which computes the
|
||||
/// value of the OperandValToReplace of the given IVStrideUse.
|
||||
|
@ -109,7 +109,7 @@ class RGPassManager : public FunctionPass, public PMDataManager {
|
||||
/// @brief Print passes managed by this manager.
|
||||
void dumpPassStructure(unsigned Offset);
|
||||
|
||||
/// @brief Print passes contained by this manager.
|
||||
/// @brief Get passes contained by this manager.
|
||||
Pass *getContainedPass(unsigned N) {
|
||||
assert(N < PassVector.size() && "Pass number out of range!");
|
||||
Pass *FP = static_cast<Pass *>(PassVector[N]);
|
||||
|
@ -270,30 +270,30 @@ namespace llvm {
|
||||
|
||||
/// BackedgeTakenCounts - Cache the backedge-taken count of the loops for
|
||||
/// this function as they are computed.
|
||||
std::map<const Loop*, BackedgeTakenInfo> BackedgeTakenCounts;
|
||||
DenseMap<const Loop*, BackedgeTakenInfo> BackedgeTakenCounts;
|
||||
|
||||
/// ConstantEvolutionLoopExitValue - This map contains entries for all of
|
||||
/// the PHI instructions that we attempt to compute constant evolutions for.
|
||||
/// This allows us to avoid potentially expensive recomputation of these
|
||||
/// properties. An instruction maps to null if we are unable to compute its
|
||||
/// exit value.
|
||||
std::map<PHINode*, Constant*> ConstantEvolutionLoopExitValue;
|
||||
DenseMap<PHINode*, Constant*> ConstantEvolutionLoopExitValue;
|
||||
|
||||
/// ValuesAtScopes - This map contains entries for all the expressions
|
||||
/// that we attempt to compute getSCEVAtScope information for, which can
|
||||
/// be expensive in extreme cases.
|
||||
std::map<const SCEV *,
|
||||
DenseMap<const SCEV *,
|
||||
std::map<const Loop *, const SCEV *> > ValuesAtScopes;
|
||||
|
||||
/// LoopDispositions - Memoized computeLoopDisposition results.
|
||||
std::map<const SCEV *,
|
||||
DenseMap<const SCEV *,
|
||||
std::map<const Loop *, LoopDisposition> > LoopDispositions;
|
||||
|
||||
/// computeLoopDisposition - Compute a LoopDisposition value.
|
||||
LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
|
||||
|
||||
/// BlockDispositions - Memoized computeBlockDisposition results.
|
||||
std::map<const SCEV *,
|
||||
DenseMap<const SCEV *,
|
||||
std::map<const BasicBlock *, BlockDisposition> > BlockDispositions;
|
||||
|
||||
/// computeBlockDisposition - Compute a BlockDisposition value.
|
||||
|
@ -51,6 +51,9 @@ class Argument : public Value, public ilist_node<Argument> {
|
||||
/// hasByValAttr - Return true if this argument has the byval attribute on it
|
||||
/// in its containing function.
|
||||
bool hasByValAttr() const;
|
||||
|
||||
/// getParamAlignment - If this is a byval argument, return its alignment.
|
||||
unsigned getParamAlignment() const;
|
||||
|
||||
/// hasNestAttr - Return true if this argument has the nest attribute on
|
||||
/// it in its containing function.
|
||||
|
@ -67,6 +67,20 @@ const Attributes StackAlignment = 7<<26; ///< Alignment of stack for
|
||||
///alignstack(1))
|
||||
const Attributes Hotpatch = 1<<29; ///< Function should have special
|
||||
///'hotpatch' sequence in prologue
|
||||
const Attributes UWTable = 1<<30; ///< Function must be in a unwind
|
||||
///table
|
||||
|
||||
/// Note that uwtable is about the ABI or the user mandating an entry in the
|
||||
/// unwind table. The nounwind attribute is about an exception passing by the
|
||||
/// function.
|
||||
/// In a theoretical system that uses tables for profiling and sjlj for
|
||||
/// exceptions, they would be fully independent. In a normal system that
|
||||
/// uses tables for both, the semantics are:
|
||||
/// nil = Needs an entry because an exception might pass by.
|
||||
/// nounwind = No need for an entry
|
||||
/// uwtable = Needs an entry because the ABI says so and because
|
||||
/// an exception might pass by.
|
||||
/// uwtable + nounwind = Needs an entry because the ABI says so.
|
||||
|
||||
/// @brief Attributes that only apply to function parameters.
|
||||
const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
||||
@ -76,7 +90,7 @@ const Attributes ParameterOnly = ByVal | Nest | StructRet | NoCapture;
|
||||
const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly |
|
||||
NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq |
|
||||
NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment |
|
||||
Hotpatch;
|
||||
Hotpatch | UWTable;
|
||||
|
||||
/// @brief Parameter attributes that do not apply to vararg call arguments.
|
||||
const Attributes VarArgsIncompatible = StructRet;
|
||||
|
@ -185,7 +185,14 @@ namespace llvm {
|
||||
|
||||
void emitPrologLabel(const MachineInstr &MI);
|
||||
|
||||
bool needsCFIMoves();
|
||||
enum CFIMoveType {
|
||||
CFI_M_None,
|
||||
CFI_M_EH,
|
||||
CFI_M_Debug
|
||||
};
|
||||
CFIMoveType needsCFIMoves();
|
||||
|
||||
bool needsSEHMoves();
|
||||
|
||||
/// EmitConstantPool - Print to the current output stream assembly
|
||||
/// representations of the constants in the constant pool MCP. This is
|
||||
@ -381,10 +388,6 @@ namespace llvm {
|
||||
/// operands.
|
||||
virtual MachineLocation getDebugValueLocation(const MachineInstr *MI) const;
|
||||
|
||||
/// getDwarfRegOpSize - get size required to emit given machine location
|
||||
/// using dwarf encoding.
|
||||
virtual unsigned getDwarfRegOpSize(const MachineLocation &MLoc) const;
|
||||
|
||||
/// getISAEncoding - Get the value for DW_AT_APPLE_isa. Zero if no isa
|
||||
/// encoding specified.
|
||||
virtual unsigned getISAEncoding() { return 0; }
|
||||
@ -396,12 +399,9 @@ namespace llvm {
|
||||
// Dwarf Lowering Routines
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// EmitFrameMoves - Emit frame instructions to describe the layout of the
|
||||
/// EmitCFIFrameMove - Emit frame instruction to describe the layout of the
|
||||
/// frame.
|
||||
void EmitFrameMoves(const std::vector<MachineMove> &Moves,
|
||||
MCSymbol *BaseLabel, bool isEH) const;
|
||||
void EmitCFIFrameMove(const MachineMove &Move) const;
|
||||
void EmitCFIFrameMoves(const std::vector<MachineMove> &Moves) const;
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Inline Asm Support
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define LLVM_CODEGEN_CALLINGCONVLOWER_H
|
||||
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/ValueTypes.h"
|
||||
#include "llvm/Target/TargetCallingConv.h"
|
||||
#include "llvm/CallingConv.h"
|
||||
@ -141,14 +142,19 @@ typedef bool CCCustomFn(unsigned &ValNo, MVT &ValVT,
|
||||
MVT &LocVT, CCValAssign::LocInfo &LocInfo,
|
||||
ISD::ArgFlagsTy &ArgFlags, CCState &State);
|
||||
|
||||
typedef enum { Invalid, Prologue, Call } ParmContext;
|
||||
/// ParmContext - This enum tracks whether calling convention lowering is in
|
||||
/// the context of prologue or call generation. Not all backends make use of
|
||||
/// this information.
|
||||
typedef enum { Unknown, Prologue, Call } ParmContext;
|
||||
|
||||
/// CCState - This class holds information needed while lowering arguments and
|
||||
/// return values. It captures which registers are already assigned and which
|
||||
/// stack slots are used. It provides accessors to allocate these values.
|
||||
class CCState {
|
||||
private:
|
||||
CallingConv::ID CallingConv;
|
||||
bool IsVarArg;
|
||||
MachineFunction &MF;
|
||||
const TargetMachine &TM;
|
||||
const TargetRegisterInfo &TRI;
|
||||
SmallVector<CCValAssign, 16> &Locs;
|
||||
@ -158,10 +164,14 @@ class CCState {
|
||||
SmallVector<uint32_t, 16> UsedRegs;
|
||||
unsigned FirstByValReg;
|
||||
bool FirstByValRegValid;
|
||||
|
||||
protected:
|
||||
ParmContext CallOrPrologue;
|
||||
|
||||
public:
|
||||
CCState(CallingConv::ID CC, bool isVarArg, const TargetMachine &TM,
|
||||
SmallVector<CCValAssign, 16> &locs, LLVMContext &C);
|
||||
CCState(CallingConv::ID CC, bool isVarArg, MachineFunction &MF,
|
||||
const TargetMachine &TM, SmallVector<CCValAssign, 16> &locs,
|
||||
LLVMContext &C);
|
||||
|
||||
void addLoc(const CCValAssign &V) {
|
||||
Locs.push_back(V);
|
||||
@ -169,6 +179,7 @@ class CCState {
|
||||
|
||||
LLVMContext &getContext() const { return Context; }
|
||||
const TargetMachine &getTarget() const { return TM; }
|
||||
MachineFunction &getMachineFunction() const { return MF; }
|
||||
CallingConv::ID getCallingConv() const { return CallingConv; }
|
||||
bool isVarArg() const { return IsVarArg; }
|
||||
|
||||
@ -301,7 +312,6 @@ class CCState {
|
||||
bool isFirstByValRegValid() { return FirstByValRegValid; }
|
||||
|
||||
ParmContext getCallOrPrologue() { return CallOrPrologue; }
|
||||
void setCallOrPrologue(ParmContext pc) { CallOrPrologue = pc; }
|
||||
|
||||
private:
|
||||
/// MarkAllocated - Mark a register and all of its aliases as allocated.
|
||||
|
@ -241,6 +241,15 @@ class FastISel {
|
||||
unsigned Op0, bool Op0IsKill,
|
||||
unsigned Op1, bool Op1IsKill);
|
||||
|
||||
/// FastEmitInst_rrr - Emit a MachineInstr with three register operands
|
||||
/// and a result register in the given register class.
|
||||
///
|
||||
unsigned FastEmitInst_rrr(unsigned MachineInstOpcode,
|
||||
const TargetRegisterClass *RC,
|
||||
unsigned Op0, bool Op0IsKill,
|
||||
unsigned Op1, bool Op1IsKill,
|
||||
unsigned Op2, bool Op2IsKill);
|
||||
|
||||
/// FastEmitInst_ri - Emit a MachineInstr with a register operand,
|
||||
/// an immediate, and a result register in the given register class.
|
||||
///
|
||||
@ -301,7 +310,7 @@ class FastISel {
|
||||
/// the CFG.
|
||||
void FastEmitBranch(MachineBasicBlock *MBB, DebugLoc DL);
|
||||
|
||||
unsigned UpdateValueMap(const Value* I, unsigned Reg);
|
||||
void UpdateValueMap(const Value* I, unsigned Reg, unsigned NumRegs = 1);
|
||||
|
||||
unsigned createResultReg(const TargetRegisterClass *RC);
|
||||
|
||||
@ -334,6 +343,8 @@ class FastISel {
|
||||
|
||||
bool SelectCast(const User *I, unsigned Opcode);
|
||||
|
||||
bool SelectExtractValue(const User *I);
|
||||
|
||||
/// HandlePHINodesInSuccessorBlocks - Handle PHI nodes in successor blocks.
|
||||
/// Emit code to ensure constants are copied into registers when needed.
|
||||
/// Remember the virtual registers that need to be added to the Machine PHI
|
||||
|
@ -107,11 +107,11 @@ namespace ISD {
|
||||
// and returns an outchain.
|
||||
EH_SJLJ_LONGJMP,
|
||||
|
||||
// OUTCHAIN = EH_SJLJ_DISPATCHSETUP(INCHAIN, context)
|
||||
// OUTCHAIN = EH_SJLJ_DISPATCHSETUP(INCHAIN, setjmpval)
|
||||
// This corresponds to the eh.sjlj.dispatchsetup intrinsic. It takes an
|
||||
// input chain and a pointer to the sjlj function context as inputs and
|
||||
// returns an outchain. By default, this does nothing. Targets can lower
|
||||
// this to unwind setup code if needed.
|
||||
// input chain and the value returning from setjmp as inputs and returns an
|
||||
// outchain. By default, this does nothing. Targets can lower this to unwind
|
||||
// setup code if needed.
|
||||
EH_SJLJ_DISPATCHSETUP,
|
||||
|
||||
// TargetConstant* - Like Constant*, but the DAG does not do any folding,
|
||||
|
@ -492,9 +492,10 @@ namespace llvm {
|
||||
|
||||
/// Returns true if the live interval is zero length, i.e. no live ranges
|
||||
/// span instructions. It doesn't pay to spill such an interval.
|
||||
bool isZeroLength() const {
|
||||
bool isZeroLength(SlotIndexes *Indexes) const {
|
||||
for (const_iterator i = begin(), e = end(); i != e; ++i)
|
||||
if (i->end.getPrevIndex() > i->start)
|
||||
if (Indexes->getNextNonNullIndex(i->start).getBaseIndex() <
|
||||
i->end.getBaseIndex())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -229,6 +229,7 @@ class MachineInstr : public ilist_node<MachineInstr> {
|
||||
|
||||
enum MICheckType {
|
||||
CheckDefs, // Check all operands for equality
|
||||
CheckKillDead, // Check all operands including kill / dead markers
|
||||
IgnoreDefs, // Ignore all definitions
|
||||
IgnoreVRegDefs // Ignore virtual register definitions
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ class MachineInstrBuilder {
|
||||
return *this;
|
||||
}
|
||||
|
||||
const MachineInstrBuilder &addFrameIndex(unsigned Idx) const {
|
||||
const MachineInstrBuilder &addFrameIndex(int Idx) const {
|
||||
MI->addOperand(MachineOperand::CreateFI(Idx));
|
||||
return *this;
|
||||
}
|
||||
|
@ -52,27 +52,13 @@ namespace llvm {
|
||||
class Constant;
|
||||
class GlobalVariable;
|
||||
class MDNode;
|
||||
class MMIAddrLabelMap;
|
||||
class MachineBasicBlock;
|
||||
class MachineFunction;
|
||||
class Module;
|
||||
class PointerType;
|
||||
class StructType;
|
||||
|
||||
/// MachineModuleInfoImpl - This class can be derived from and used by targets
|
||||
/// to hold private target-specific information for each Module. Objects of
|
||||
/// type are accessed/created with MMI::getInfo and destroyed when the
|
||||
/// MachineModuleInfo is destroyed.
|
||||
class MachineModuleInfoImpl {
|
||||
public:
|
||||
typedef PointerIntPair<MCSymbol*, 1, bool> StubValueTy;
|
||||
virtual ~MachineModuleInfoImpl();
|
||||
typedef std::vector<std::pair<MCSymbol*, StubValueTy> > SymbolListTy;
|
||||
protected:
|
||||
static SymbolListTy GetSortedStubs(const DenseMap<MCSymbol*, StubValueTy>&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// LandingPadInfo - This structure is used to retain landing pad info for
|
||||
/// the current function.
|
||||
@ -89,7 +75,20 @@ struct LandingPadInfo {
|
||||
: LandingPadBlock(MBB), LandingPadLabel(0), Personality(0) {}
|
||||
};
|
||||
|
||||
class MMIAddrLabelMap;
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// MachineModuleInfoImpl - This class can be derived from and used by targets
|
||||
/// to hold private target-specific information for each Module. Objects of
|
||||
/// type are accessed/created with MMI::getInfo and destroyed when the
|
||||
/// MachineModuleInfo is destroyed.
|
||||
///
|
||||
class MachineModuleInfoImpl {
|
||||
public:
|
||||
typedef PointerIntPair<MCSymbol*, 1, bool> StubValueTy;
|
||||
virtual ~MachineModuleInfoImpl();
|
||||
typedef std::vector<std::pair<MCSymbol*, StubValueTy> > SymbolListTy;
|
||||
protected:
|
||||
static SymbolListTy GetSortedStubs(const DenseMap<MCSymbol*, StubValueTy>&);
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// MachineModuleInfo - This class contains meta information specific to a
|
||||
|
@ -94,8 +94,8 @@ class MachineOperand {
|
||||
/// not a real instruction. Such uses should be ignored during codegen.
|
||||
bool IsDebug : 1;
|
||||
|
||||
/// SmallContents - Thisreally should be part of the Contents union, but lives
|
||||
/// out here so we can get a better packed struct.
|
||||
/// SmallContents - This really should be part of the Contents union, but
|
||||
/// lives out here so we can get a better packed struct.
|
||||
/// MO_Register: Register number.
|
||||
/// OffsetedInfo: Low bits of offset.
|
||||
union {
|
||||
@ -473,7 +473,7 @@ class MachineOperand {
|
||||
Op.setTargetFlags(TargetFlags);
|
||||
return Op;
|
||||
}
|
||||
static MachineOperand CreateFI(unsigned Idx) {
|
||||
static MachineOperand CreateFI(int Idx) {
|
||||
MachineOperand Op(MachineOperand::MO_FrameIndex);
|
||||
Op.setIndex(Idx);
|
||||
return Op;
|
||||
|
@ -21,7 +21,7 @@ namespace llvm {
|
||||
class raw_ostream;
|
||||
|
||||
/// PseudoSourceValue - Special value supplied for machine level alias
|
||||
/// analysis. It indicates that the a memory access references the functions
|
||||
/// analysis. It indicates that a memory access references the functions
|
||||
/// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
|
||||
/// space), or constant pool.
|
||||
class PseudoSourceValue : public Value {
|
||||
|
@ -94,7 +94,7 @@ namespace llvm {
|
||||
typedef std::map<PBQP::Graph::ConstNodeItr, unsigned,
|
||||
PBQP::NodeItrComparator> Node2VReg;
|
||||
typedef DenseMap<unsigned, PBQP::Graph::NodeItr> VReg2Node;
|
||||
typedef std::map<unsigned, AllowedSet> AllowedSetMap;
|
||||
typedef DenseMap<unsigned, AllowedSet> AllowedSetMap;
|
||||
|
||||
PBQP::Graph graph;
|
||||
Node2VReg node2VReg;
|
||||
|
@ -265,7 +265,6 @@ namespace llvm {
|
||||
bool isCloned : 1; // True if this node has been cloned.
|
||||
Sched::Preference SchedulingPref; // Scheduling preference.
|
||||
|
||||
SmallVector<MachineInstr*, 4> DbgInstrList; // dbg_values referencing this.
|
||||
private:
|
||||
bool isDepthCurrent : 1; // True if Depth is current.
|
||||
bool isHeightCurrent : 1; // True if Height is current.
|
||||
|
@ -284,7 +284,7 @@ class SelectionDAG {
|
||||
///
|
||||
/// Note that this is an involved process that may invalidate pointers into
|
||||
/// the graph.
|
||||
void Legalize(CodeGenOpt::Level OptLevel);
|
||||
void Legalize();
|
||||
|
||||
/// LegalizeVectors - This transforms the SelectionDAG into a SelectionDAG
|
||||
/// that only uses vector math operations supported by the target. This is
|
||||
@ -985,10 +985,6 @@ class SelectionDAG {
|
||||
/// other positive zero.
|
||||
bool isEqualTo(SDValue A, SDValue B) const;
|
||||
|
||||
/// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has
|
||||
/// been verified as a debug information descriptor.
|
||||
bool isVerifiedDebugInfoDesc(SDValue Op) const;
|
||||
|
||||
/// UnrollVectorOp - Utility function used by legalize and lowering to
|
||||
/// "unroll" a vector operation by splitting out the scalars and operating
|
||||
/// on each element individually. If the ResNE is 0, fully unroll the vector
|
||||
|
@ -58,6 +58,10 @@ class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||
|
||||
virtual const MCSection *getEHFrameSection() const;
|
||||
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
|
||||
return NULL;
|
||||
}
|
||||
virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
|
||||
|
||||
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
||||
const TargetMachine &TM,
|
||||
@ -133,6 +137,10 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||
|
||||
virtual const MCSection *getEHFrameSection() const;
|
||||
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
|
||||
return NULL;
|
||||
}
|
||||
virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
|
||||
|
||||
virtual const MCSection *
|
||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
@ -196,6 +204,8 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
||||
|
||||
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
||||
const MCSection *DrectveSection;
|
||||
const MCSection *PDataSection;
|
||||
const MCSection *XDataSection;
|
||||
public:
|
||||
TargetLoweringObjectFileCOFF() {}
|
||||
~TargetLoweringObjectFileCOFF() {}
|
||||
@ -203,6 +213,8 @@ class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||
|
||||
virtual const MCSection *getEHFrameSection() const;
|
||||
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const;
|
||||
virtual const MCSection *getWin64EHTableSection(StringRef) const;
|
||||
|
||||
virtual const MCSection *getDrectveSection() const { return DrectveSection; }
|
||||
|
||||
|
@ -56,8 +56,11 @@ def forward_not_split;
|
||||
def case;
|
||||
|
||||
// Boolean constants.
|
||||
def true;
|
||||
def false;
|
||||
class Bool<bit val> {
|
||||
bit Value = val;
|
||||
}
|
||||
def true : Bool<1>;
|
||||
def false : Bool<0>;
|
||||
|
||||
// Boolean operators.
|
||||
def and;
|
||||
|
167
contrib/llvm/include/llvm/DefaultPasses.h
Normal file
167
contrib/llvm/include/llvm/DefaultPasses.h
Normal file
@ -0,0 +1,167 @@
|
||||
//===- llvm/DefaultPasses.h - Default Pass Support code --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// This file defines the infrastructure for registering the standard pass list.
|
||||
// This defines sets of standard optimizations that plugins can modify and
|
||||
// front ends can use.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_DEFAULT_PASS_SUPPORT_H
|
||||
#define LLVM_DEFAULT_PASS_SUPPORT_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class PassManagerBase;
|
||||
|
||||
/// Unique identifiers for the default standard passes. The addresses of
|
||||
/// these symbols are used to uniquely identify passes from the default list.
|
||||
namespace DefaultStandardPasses {
|
||||
extern unsigned char AggressiveDCEID;
|
||||
extern unsigned char ArgumentPromotionID;
|
||||
extern unsigned char BasicAliasAnalysisID;
|
||||
extern unsigned char CFGSimplificationID;
|
||||
extern unsigned char ConstantMergeID;
|
||||
extern unsigned char CorrelatedValuePropagationID;
|
||||
extern unsigned char DeadArgEliminationID;
|
||||
extern unsigned char DeadStoreEliminationID;
|
||||
extern unsigned char DeadTypeEliminationID;
|
||||
extern unsigned char EarlyCSEID;
|
||||
extern unsigned char FunctionAttrsID;
|
||||
extern unsigned char FunctionInliningID;
|
||||
extern unsigned char GVNID;
|
||||
extern unsigned char GlobalDCEID;
|
||||
extern unsigned char GlobalOptimizerID;
|
||||
extern unsigned char GlobalsModRefID;
|
||||
extern unsigned char IPSCCPID;
|
||||
extern unsigned char IndVarSimplifyID;
|
||||
extern unsigned char InlinerPlaceholderID;
|
||||
extern unsigned char InstructionCombiningID;
|
||||
extern unsigned char JumpThreadingID;
|
||||
extern unsigned char LICMID;
|
||||
extern unsigned char LoopDeletionID;
|
||||
extern unsigned char LoopIdiomID;
|
||||
extern unsigned char LoopRotateID;
|
||||
extern unsigned char LoopUnrollID;
|
||||
extern unsigned char LoopUnswitchID;
|
||||
extern unsigned char MemCpyOptID;
|
||||
extern unsigned char PruneEHID;
|
||||
extern unsigned char ReassociateID;
|
||||
extern unsigned char SCCPID;
|
||||
extern unsigned char ScalarReplAggregatesID;
|
||||
extern unsigned char SimplifyLibCallsID;
|
||||
extern unsigned char StripDeadPrototypesID;
|
||||
extern unsigned char TailCallEliminationID;
|
||||
extern unsigned char TypeBasedAliasAnalysisID;
|
||||
}
|
||||
|
||||
/// StandardPass - The class responsible for maintaining the lists of standard
|
||||
class StandardPass {
|
||||
friend class RegisterStandardPassLists;
|
||||
public:
|
||||
/// Predefined standard sets of passes
|
||||
enum StandardSet {
|
||||
AliasAnalysis,
|
||||
Function,
|
||||
Module,
|
||||
LTO
|
||||
};
|
||||
/// Flags to specify whether a pass should be enabled. Passes registered
|
||||
/// with the standard sets may specify a minimum optimization level and one
|
||||
/// or more flags that must be set when constructing the set for the pass to
|
||||
/// be used.
|
||||
enum OptimizationFlags {
|
||||
/// Optimize for size was requested.
|
||||
OptimizeSize = 1<<0,
|
||||
/// Allow passes which may make global module changes.
|
||||
UnitAtATime = 1<<1,
|
||||
/// UnrollLoops - Allow loop unrolling.
|
||||
UnrollLoops = 1<<2,
|
||||
/// Allow library calls to be simplified.
|
||||
SimplifyLibCalls = 1<<3,
|
||||
/// Whether the module may have code using exceptions.
|
||||
HaveExceptions = 1<<4,
|
||||
// Run an inliner pass as part of this set.
|
||||
RunInliner = 1<<5
|
||||
};
|
||||
enum OptimizationFlagComponents {
|
||||
/// The low bits are used to store the optimization level. When requesting
|
||||
/// passes, this should store the requested optimisation level. When
|
||||
/// setting passes, this should set the minimum optimization level at which
|
||||
/// the pass will run.
|
||||
OptimizationLevelMask=0xf,
|
||||
/// The maximum optimisation level at which the pass is run.
|
||||
MaxOptimizationLevelMask=0xf0,
|
||||
// Flags that must be set
|
||||
RequiredFlagMask=0xff00,
|
||||
// Flags that may not be set.
|
||||
DisallowedFlagMask=0xff0000,
|
||||
MaxOptimizationLevelShift=4,
|
||||
RequiredFlagShift=8,
|
||||
DisallowedFlagShift=16
|
||||
};
|
||||
/// Returns the optimisation level from a set of flags.
|
||||
static unsigned OptimizationLevel(unsigned flags) {
|
||||
return flags & OptimizationLevelMask;
|
||||
}
|
||||
/// Returns the maximum optimization level for this set of flags
|
||||
static unsigned MaxOptimizationLevel(unsigned flags) {
|
||||
return (flags & MaxOptimizationLevelMask) >> 4;
|
||||
}
|
||||
/// Constructs a set of flags from the specified minimum and maximum
|
||||
/// optimisation level
|
||||
static unsigned OptimzationFlags(unsigned minLevel=0, unsigned maxLevel=0xf,
|
||||
unsigned requiredFlags=0, unsigned disallowedFlags=0) {
|
||||
return ((minLevel & OptimizationLevelMask) |
|
||||
((maxLevel<<MaxOptimizationLevelShift) & MaxOptimizationLevelMask)
|
||||
| ((requiredFlags<<RequiredFlagShift) & RequiredFlagMask)
|
||||
| ((disallowedFlags<<DisallowedFlagShift) & DisallowedFlagMask));
|
||||
}
|
||||
/// Returns the flags that must be set for this to match
|
||||
static unsigned RequiredFlags(unsigned flags) {
|
||||
return (flags & RequiredFlagMask) >> RequiredFlagShift;
|
||||
}
|
||||
/// Returns the flags that must not be set for this to match
|
||||
static unsigned DisallowedFlags(unsigned flags) {
|
||||
return (flags & DisallowedFlagMask) >> DisallowedFlagShift;
|
||||
}
|
||||
/// Register a standard pass in the specified set. If flags is non-zero,
|
||||
/// then the pass will only be returned when the specified flags are set.
|
||||
template<typename passName>
|
||||
class RegisterStandardPass {
|
||||
public:
|
||||
RegisterStandardPass(StandardSet set, unsigned char *runBefore=0,
|
||||
unsigned flags=0, unsigned char *ID=0) {
|
||||
// Use the pass's ID if one is not specified
|
||||
RegisterDefaultPass(PassInfo::NormalCtor_t(callDefaultCtor<passName>),
|
||||
ID ? ID : (unsigned char*)&passName::ID, runBefore, set, flags);
|
||||
}
|
||||
};
|
||||
/// Adds the passes from the specified set to the provided pass manager
|
||||
static void AddPassesFromSet(PassManagerBase *PM,
|
||||
StandardSet set,
|
||||
unsigned flags=0,
|
||||
bool VerifyEach=false,
|
||||
Pass *inliner=0);
|
||||
private:
|
||||
/// Registers the default passes. This is set by RegisterStandardPassLists
|
||||
/// and is called lazily.
|
||||
static void (*RegisterDefaultPasses)(void);
|
||||
/// Creates the verifier pass that is inserted when a VerifyEach is passed to
|
||||
/// AddPassesFromSet()
|
||||
static Pass* (*CreateVerifierPass)(void);
|
||||
/// Registers the pass
|
||||
static void RegisterDefaultPass(PassInfo::NormalCtor_t constructor,
|
||||
unsigned char *newPass,
|
||||
unsigned char *oldPass,
|
||||
StandardSet set,
|
||||
unsigned flags=0);
|
||||
};
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
@ -135,20 +135,14 @@ class ExecutionEngine {
|
||||
JITMemoryManager *JMM,
|
||||
CodeGenOpt::Level OptLevel,
|
||||
bool GVsWithCode,
|
||||
CodeModel::Model CMM,
|
||||
StringRef MArch,
|
||||
StringRef MCPU,
|
||||
const SmallVectorImpl<std::string>& MAttrs);
|
||||
TargetMachine *TM);
|
||||
static ExecutionEngine *(*MCJITCtor)(
|
||||
Module *M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
CodeGenOpt::Level OptLevel,
|
||||
bool GVsWithCode,
|
||||
CodeModel::Model CMM,
|
||||
StringRef MArch,
|
||||
StringRef MCPU,
|
||||
const SmallVectorImpl<std::string>& MAttrs);
|
||||
TargetMachine *TM);
|
||||
static ExecutionEngine *(*InterpCtor)(Module *M,
|
||||
std::string *ErrorStr);
|
||||
|
||||
@ -569,6 +563,14 @@ class EngineBuilder {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// selectTarget - Pick a target either via -march or by guessing the native
|
||||
/// arch. Add any CPU features specified via -mcpu or -mattr.
|
||||
static TargetMachine *selectTarget(Module *M,
|
||||
StringRef MArch,
|
||||
StringRef MCPU,
|
||||
const SmallVectorImpl<std::string>& MAttrs,
|
||||
std::string *Err);
|
||||
|
||||
ExecutionEngine *create();
|
||||
};
|
||||
|
||||
|
@ -253,6 +253,23 @@ class Function : public GlobalValue,
|
||||
else removeFnAttr(Attribute::NoUnwind);
|
||||
}
|
||||
|
||||
/// @brief True if the ABI mandates (or the user requested) that this
|
||||
/// function be in a unwind table.
|
||||
bool hasUWTable() const {
|
||||
return hasFnAttr(Attribute::UWTable);
|
||||
}
|
||||
void setHasUWTable(bool HasUWTable = true) {
|
||||
if (HasUWTable)
|
||||
addFnAttr(Attribute::UWTable);
|
||||
else
|
||||
removeFnAttr(Attribute::UWTable);
|
||||
}
|
||||
|
||||
/// @brief True if this function needs an unwind table.
|
||||
bool needsUnwindTableEntry() const {
|
||||
return hasUWTable() || !doesNotThrow();
|
||||
}
|
||||
|
||||
/// @brief Determine if the function returns a structure through first
|
||||
/// pointer argument.
|
||||
bool hasStructRetAttr() const {
|
||||
@ -414,6 +431,10 @@ class Function : public GlobalValue,
|
||||
///
|
||||
bool hasAddressTaken(const User** = 0) const;
|
||||
|
||||
/// callsFunctionThatReturnsTwice - Return true if the function has a call to
|
||||
/// setjmp or other function that gcc recognizes as "returning twice".
|
||||
bool callsFunctionThatReturnsTwice() const;
|
||||
|
||||
private:
|
||||
// Shadow Value::setValueSubclassData with a private forwarding method so that
|
||||
// subclasses cannot accidentally use it.
|
||||
|
@ -66,6 +66,7 @@ void initializeBasicAliasAnalysisPass(PassRegistry&);
|
||||
void initializeBasicCallGraphPass(PassRegistry&);
|
||||
void initializeBlockExtractorPassPass(PassRegistry&);
|
||||
void initializeBlockPlacementPass(PassRegistry&);
|
||||
void initializeBranchProbabilityInfoPass(PassRegistry&);
|
||||
void initializeBreakCriticalEdgesPass(PassRegistry&);
|
||||
void initializeCFGOnlyPrinterPass(PassRegistry&);
|
||||
void initializeCFGOnlyViewerPass(PassRegistry&);
|
||||
|
@ -139,7 +139,7 @@ namespace llvm {
|
||||
return !getVolatileCst()->isZero();
|
||||
}
|
||||
|
||||
unsigned getAddressSpace() const {
|
||||
unsigned getDestAddressSpace() const {
|
||||
return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
|
||||
}
|
||||
|
||||
@ -227,6 +227,10 @@ namespace llvm {
|
||||
/// value is guaranteed to be a pointer.
|
||||
Value *getSource() const { return getRawSource()->stripPointerCasts(); }
|
||||
|
||||
unsigned getSourceAddressSpace() const {
|
||||
return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
|
||||
}
|
||||
|
||||
void setSource(Value *Ptr) {
|
||||
assert(getRawSource()->getType() == Ptr->getType() &&
|
||||
"setSource called with pointer of wrong type!");
|
||||
|
@ -47,6 +47,9 @@ def IntrReadWriteArgMem : IntrinsicProperty;
|
||||
// Commutative - This intrinsic is commutative: X op Y == Y op X.
|
||||
def Commutative : IntrinsicProperty;
|
||||
|
||||
// Throws - This intrinsic can throw.
|
||||
def Throws : IntrinsicProperty;
|
||||
|
||||
// NoCapture - The specified argument pointer is not captured by the intrinsic.
|
||||
class NoCapture<int argNo> : IntrinsicProperty {
|
||||
int ArgNo = argNo;
|
||||
@ -292,6 +295,7 @@ let Properties = [IntrNoMem] in {
|
||||
def int_eh_exception : Intrinsic<[llvm_ptr_ty], [], [IntrReadMem]>;
|
||||
def int_eh_selector : Intrinsic<[llvm_i32_ty],
|
||||
[llvm_ptr_ty, llvm_ptr_ty, llvm_vararg_ty]>;
|
||||
def int_eh_resume : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [Throws]>;
|
||||
|
||||
def int_eh_typeid_for : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
|
||||
|
||||
@ -307,7 +311,7 @@ let Properties = [IntrNoMem] in {
|
||||
def int_eh_sjlj_lsda : Intrinsic<[llvm_ptr_ty]>;
|
||||
def int_eh_sjlj_callsite: Intrinsic<[], [llvm_i32_ty]>;
|
||||
}
|
||||
def int_eh_sjlj_dispatch_setup : Intrinsic<[], []>;
|
||||
def int_eh_sjlj_dispatch_setup : Intrinsic<[], [llvm_i32_ty], [IntrReadMem]>;
|
||||
def int_eh_sjlj_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
|
||||
def int_eh_sjlj_longjmp : Intrinsic<[], [llvm_ptr_ty]>;
|
||||
|
||||
|
@ -35,6 +35,16 @@ let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.".
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Load and Store exclusive doubleword
|
||||
|
||||
let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.".
|
||||
def int_arm_strexd : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_ptr_ty], [IntrReadWriteArgMem]>;
|
||||
def int_arm_ldrexd : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [llvm_ptr_ty],
|
||||
[IntrReadArgMem]>;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// VFP
|
||||
|
||||
@ -49,6 +59,43 @@ let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.".
|
||||
[IntrNoMem]>;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Coprocessor
|
||||
|
||||
let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.".
|
||||
// Move to coprocessor
|
||||
def int_arm_mcr : GCCBuiltin<"__builtin_arm_mcr">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>;
|
||||
def int_arm_mcr2 : GCCBuiltin<"__builtin_arm_mcr2">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>;
|
||||
|
||||
// Move from coprocessor
|
||||
def int_arm_mrc : GCCBuiltin<"__builtin_arm_mrc">,
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty], []>;
|
||||
def int_arm_mrc2 : GCCBuiltin<"__builtin_arm_mrc2">,
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty], []>;
|
||||
|
||||
// Coprocessor data processing
|
||||
def int_arm_cdp : GCCBuiltin<"__builtin_arm_cdp">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>;
|
||||
def int_arm_cdp2 : GCCBuiltin<"__builtin_arm_cdp2">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>;
|
||||
|
||||
// Move from two registers to coprocessor
|
||||
def int_arm_mcrr : GCCBuiltin<"__builtin_arm_mcrr">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty], []>;
|
||||
def int_arm_mcrr2 : GCCBuiltin<"__builtin_arm_mcrr2">,
|
||||
Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
|
||||
llvm_i32_ty, llvm_i32_ty], []>;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Advanced SIMD (NEON)
|
||||
|
||||
|
@ -224,9 +224,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
|
||||
// Cacheability support ops
|
||||
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
def int_x86_sse_movnt_ps : GCCBuiltin<"__builtin_ia32_movntps">,
|
||||
Intrinsic<[], [llvm_ptr_ty,
|
||||
llvm_v4f32_ty], []>;
|
||||
def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">,
|
||||
Intrinsic<[], [], []>;
|
||||
}
|
||||
@ -536,19 +533,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
llvm_v4i32_ty], []>;
|
||||
}
|
||||
|
||||
// Cacheability support ops
|
||||
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
def int_x86_sse2_movnt_dq : GCCBuiltin<"__builtin_ia32_movntdq">,
|
||||
Intrinsic<[], [llvm_ptr_ty,
|
||||
llvm_v2i64_ty], []>;
|
||||
def int_x86_sse2_movnt_pd : GCCBuiltin<"__builtin_ia32_movntpd">,
|
||||
Intrinsic<[], [llvm_ptr_ty,
|
||||
llvm_v2f64_ty], []>;
|
||||
def int_x86_sse2_movnt_i : GCCBuiltin<"__builtin_ia32_movnti">,
|
||||
Intrinsic<[], [llvm_ptr_ty,
|
||||
llvm_i32_ty], []>;
|
||||
}
|
||||
|
||||
// Misc.
|
||||
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">,
|
||||
@ -964,19 +948,19 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
// Miscellaneous
|
||||
// CRC Instruction
|
||||
let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
|
||||
def int_x86_sse42_crc32_8 : GCCBuiltin<"__builtin_ia32_crc32qi">,
|
||||
def int_x86_sse42_crc32_32_8 : GCCBuiltin<"__builtin_ia32_crc32qi">,
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i8_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_x86_sse42_crc32_16 : GCCBuiltin<"__builtin_ia32_crc32hi">,
|
||||
def int_x86_sse42_crc32_32_16 : GCCBuiltin<"__builtin_ia32_crc32hi">,
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i16_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_x86_sse42_crc32_32 : GCCBuiltin<"__builtin_ia32_crc32si">,
|
||||
def int_x86_sse42_crc32_32_32 : GCCBuiltin<"__builtin_ia32_crc32si">,
|
||||
Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_x86_sse42_crc64_8 :
|
||||
def int_x86_sse42_crc32_64_8 :
|
||||
Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i8_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_x86_sse42_crc64_64 : GCCBuiltin<"__builtin_ia32_crc32di">,
|
||||
def int_x86_sse42_crc32_64_64 : GCCBuiltin<"__builtin_ia32_crc32di">,
|
||||
Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty],
|
||||
[IntrNoMem]>;
|
||||
}
|
||||
|
@ -11,6 +11,12 @@
|
||||
let TargetPrefix = "xcore" in { // All intrinsics start with "llvm.xcore.".
|
||||
// Miscellaneous instructions.
|
||||
def int_xcore_bitrev : Intrinsic<[llvm_i32_ty],[llvm_i32_ty],[IntrNoMem]>;
|
||||
def int_xcore_crc8 : Intrinsic<[llvm_i32_ty, llvm_i32_ty],
|
||||
[llvm_i32_ty,llvm_i32_ty,llvm_i32_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_xcore_crc32 : Intrinsic<[llvm_i32_ty],
|
||||
[llvm_i32_ty,llvm_i32_ty,llvm_i32_ty],
|
||||
[IntrNoMem]>;
|
||||
def int_xcore_getid : Intrinsic<[llvm_i32_ty],[],[IntrNoMem]>;
|
||||
def int_xcore_getps : Intrinsic<[llvm_i32_ty],[llvm_i32_ty]>;
|
||||
def int_xcore_setps : Intrinsic<[],[llvm_i32_ty, llvm_i32_ty]>;
|
||||
|
@ -70,7 +70,7 @@ namespace {
|
||||
(void) llvm::createEdgeProfilerPass();
|
||||
(void) llvm::createOptimalEdgeProfilerPass();
|
||||
(void) llvm::createPathProfilerPass();
|
||||
(void) llvm::createGCOVProfilerPass(true, true);
|
||||
(void) llvm::createGCOVProfilerPass(true, true, false);
|
||||
(void) llvm::createFunctionInliningPass();
|
||||
(void) llvm::createAlwaysInlinerPass();
|
||||
(void) llvm::createGlobalDCEPass();
|
||||
|
@ -26,12 +26,12 @@ namespace llvm {
|
||||
class MCSymbol;
|
||||
class MCContext;
|
||||
|
||||
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
||||
/// properties and features specific to the target.
|
||||
namespace ExceptionHandling {
|
||||
enum ExceptionsType { None, DwarfTable, DwarfCFI, SjLj, ARM };
|
||||
enum ExceptionsType { None, DwarfCFI, SjLj, ARM, Win64 };
|
||||
}
|
||||
|
||||
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
||||
/// properties and features specific to the target.
|
||||
class MCAsmInfo {
|
||||
protected:
|
||||
//===------------------------------------------------------------------===//
|
||||
@ -269,9 +269,6 @@ namespace llvm {
|
||||
/// SupportsExceptionHandling - True if target supports exception handling.
|
||||
ExceptionHandling::ExceptionsType ExceptionsType; // Defaults to None
|
||||
|
||||
/// RequiresFrameSection - true if the Dwarf2 output needs a frame section
|
||||
bool DwarfRequiresFrameSection; // Defaults to true.
|
||||
|
||||
/// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to
|
||||
/// encode inline subroutine information.
|
||||
bool DwarfUsesInlineInfoSection; // Defaults to false.
|
||||
@ -279,9 +276,9 @@ namespace llvm {
|
||||
/// DwarfSectionOffsetDirective - Special section offset directive.
|
||||
const char* DwarfSectionOffsetDirective; // Defaults to NULL
|
||||
|
||||
/// DwarfUsesAbsoluteLabelForStmtList - True if DW_AT_stmt_list needs
|
||||
/// absolute label instead of offset.
|
||||
bool DwarfUsesAbsoluteLabelForStmtList; // Defaults to true;
|
||||
/// DwarfRequiresRelocationForSectionOffset - True if we need to produce a
|
||||
// relocation when we want a section offset in dwarf.
|
||||
bool DwarfRequiresRelocationForSectionOffset; // Defaults to true;
|
||||
|
||||
// DwarfUsesLabelOffsetDifference - True if Dwarf2 output can
|
||||
// use EmitLabelOffsetDifference.
|
||||
@ -462,13 +459,9 @@ namespace llvm {
|
||||
}
|
||||
bool isExceptionHandlingDwarf() const {
|
||||
return
|
||||
(ExceptionsType == ExceptionHandling::DwarfTable ||
|
||||
ExceptionsType == ExceptionHandling::DwarfCFI ||
|
||||
ExceptionsType == ExceptionHandling::ARM);
|
||||
}
|
||||
|
||||
bool doesDwarfRequireFrameSection() const {
|
||||
return DwarfRequiresFrameSection;
|
||||
(ExceptionsType == ExceptionHandling::DwarfCFI ||
|
||||
ExceptionsType == ExceptionHandling::ARM ||
|
||||
ExceptionsType == ExceptionHandling::Win64);
|
||||
}
|
||||
bool doesDwarfUsesInlineInfoSection() const {
|
||||
return DwarfUsesInlineInfoSection;
|
||||
@ -476,8 +469,8 @@ namespace llvm {
|
||||
const char *getDwarfSectionOffsetDirective() const {
|
||||
return DwarfSectionOffsetDirective;
|
||||
}
|
||||
bool doesDwarfUsesAbsoluteLabelForStmtList() const {
|
||||
return DwarfUsesAbsoluteLabelForStmtList;
|
||||
bool doesDwarfRequireRelocationForSectionOffset() const {
|
||||
return DwarfRequiresRelocationForSectionOffset;
|
||||
}
|
||||
bool doesDwarfUsesLabelOffsetForRanges() const {
|
||||
return DwarfUsesLabelOffsetForRanges;
|
||||
|
@ -281,11 +281,10 @@ namespace llvm {
|
||||
//
|
||||
// This emits the frame info section.
|
||||
//
|
||||
static void Emit(MCStreamer &streamer, bool usingCFI);
|
||||
static void EmitDarwin(MCStreamer &streamer, bool usingCFI);
|
||||
static void Emit(MCStreamer &streamer, bool usingCFI,
|
||||
bool isEH);
|
||||
static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta);
|
||||
static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS,
|
||||
const TargetAsmInfo &AsmInfo);
|
||||
static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS);
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -49,7 +49,8 @@ namespace llvm {
|
||||
ELF_STV_Hidden = (ELF::STV_HIDDEN << ELF_STV_Shift),
|
||||
ELF_STV_Protected = (ELF::STV_PROTECTED << ELF_STV_Shift),
|
||||
|
||||
ELF_Other_Weakref = (1 << ELF_Other_Shift)
|
||||
ELF_Other_Weakref = (1 << ELF_Other_Shift),
|
||||
ELF_Other_ThumbFunc = (2 << ELF_Other_Shift)
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -171,8 +171,10 @@ class MCSymbolRefExpr : public MCExpr {
|
||||
VK_ARM_GOTTPOFF,
|
||||
|
||||
VK_PPC_TOC,
|
||||
VK_PPC_HA16, // ha16(symbol)
|
||||
VK_PPC_LO16 // lo16(symbol)
|
||||
VK_PPC_DARWIN_HA16, // ha16(symbol)
|
||||
VK_PPC_DARWIN_LO16, // lo16(symbol)
|
||||
VK_PPC_GAS_HA16, // symbol@ha
|
||||
VK_PPC_GAS_LO16 // symbol@l
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -45,8 +45,8 @@ class MCInstPrinter {
|
||||
/// "MOV32ri") or empty if we can't resolve it.
|
||||
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||
|
||||
/// getRegName - Return the assembler register name.
|
||||
virtual StringRef getRegName(unsigned RegNo) const;
|
||||
/// printRegName - Print the assembler register name.
|
||||
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
|
||||
|
||||
unsigned getAvailableFeatures() const { return AvailableFeatures; }
|
||||
void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
|
||||
|
@ -44,6 +44,7 @@ class AsmToken {
|
||||
Colon,
|
||||
Plus, Minus, Tilde,
|
||||
Slash, // '/'
|
||||
BackSlash, // '\'
|
||||
LParen, RParen, LBrac, RBrac, LCurly, RCurly,
|
||||
Star, Dot, Comma, Dollar, Equal, EqualEqual,
|
||||
|
||||
|
@ -71,7 +71,9 @@ class MCAsmParser {
|
||||
|
||||
/// Warning - Emit a warning at the location \arg L, with the message \arg
|
||||
/// Msg.
|
||||
virtual void Warning(SMLoc L, const Twine &Msg) = 0;
|
||||
///
|
||||
/// \return The return value is true, if warnings are fatal.
|
||||
virtual bool Warning(SMLoc L, const Twine &Msg) = 0;
|
||||
|
||||
/// Error - Emit an error at the location \arg L, with the message \arg
|
||||
/// Msg.
|
||||
|
@ -56,7 +56,7 @@ class MCAsmParserExtension {
|
||||
MCAsmParser &getParser() { return *Parser; }
|
||||
SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
|
||||
MCStreamer &getStreamer() { return getParser().getStreamer(); }
|
||||
void Warning(SMLoc L, const Twine &Msg) {
|
||||
bool Warning(SMLoc L, const Twine &Msg) {
|
||||
return getParser().Warning(L, Msg);
|
||||
}
|
||||
bool Error(SMLoc L, const Twine &Msg) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/MC/MCDirectives.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/MC/MCWin64EH.h"
|
||||
|
||||
namespace llvm {
|
||||
class MCAsmInfo;
|
||||
@ -50,10 +51,18 @@ namespace llvm {
|
||||
MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT
|
||||
MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT
|
||||
|
||||
bool EmitEHFrame;
|
||||
bool EmitDebugFrame;
|
||||
|
||||
std::vector<MCDwarfFrameInfo> FrameInfos;
|
||||
MCDwarfFrameInfo *getCurrentFrameInfo();
|
||||
void EnsureValidFrame();
|
||||
|
||||
std::vector<MCWin64EHUnwindInfo *> W64UnwindInfos;
|
||||
MCWin64EHUnwindInfo *CurrentW64UnwindInfo;
|
||||
void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame);
|
||||
void EnsureValidW64UnwindInfo();
|
||||
|
||||
const MCSymbol* LastNonPrivate;
|
||||
|
||||
/// SectionStack - This is stack of current and previous section
|
||||
@ -67,8 +76,12 @@ namespace llvm {
|
||||
const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
|
||||
const MCSymbol *B);
|
||||
|
||||
const MCExpr *ForceExpAbs(MCStreamer *Streamer, MCContext &Context,
|
||||
const MCExpr* Expr);
|
||||
const MCExpr *ForceExpAbs(const MCExpr* Expr);
|
||||
|
||||
void EmitFrames(bool usingCFI);
|
||||
|
||||
MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;}
|
||||
void EmitW64Tables();
|
||||
|
||||
public:
|
||||
virtual ~MCStreamer();
|
||||
@ -83,6 +96,14 @@ namespace llvm {
|
||||
return FrameInfos[i];
|
||||
}
|
||||
|
||||
unsigned getNumW64UnwindInfos() {
|
||||
return W64UnwindInfos.size();
|
||||
}
|
||||
|
||||
MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) {
|
||||
return *W64UnwindInfos[i];
|
||||
}
|
||||
|
||||
/// @name Assembly File Formatting.
|
||||
/// @{
|
||||
|
||||
@ -174,6 +195,17 @@ namespace llvm {
|
||||
}
|
||||
}
|
||||
|
||||
/// SwitchSectionNoChange - Set the current section where code is being
|
||||
/// emitted to @p Section. This is required to update CurSection. This
|
||||
/// version does not call ChangeSection.
|
||||
void SwitchSectionNoChange(const MCSection *Section) {
|
||||
assert(Section && "Cannot switch to a null section!");
|
||||
const MCSection *curSection = SectionStack.back().first;
|
||||
SectionStack.back().second = curSection;
|
||||
if (Section != curSection)
|
||||
SectionStack.back().first = Section;
|
||||
}
|
||||
|
||||
/// InitSections - Create the default sections and set the initial one.
|
||||
virtual void InitSections() = 0;
|
||||
|
||||
@ -288,6 +320,7 @@ namespace llvm {
|
||||
/// if non-zero. This must be a power of 2 on some targets.
|
||||
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
|
||||
uint64_t Size, unsigned ByteAlignment = 0) = 0;
|
||||
|
||||
/// @}
|
||||
/// @name Generating Data
|
||||
/// @{
|
||||
@ -436,6 +469,7 @@ namespace llvm {
|
||||
void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
|
||||
int PointerSize);
|
||||
|
||||
virtual void EmitCFISections(bool EH, bool Debug);
|
||||
virtual void EmitCFIStartProc();
|
||||
virtual void EmitCFIEndProc();
|
||||
virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset);
|
||||
@ -450,6 +484,21 @@ namespace llvm {
|
||||
virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset);
|
||||
virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment);
|
||||
|
||||
virtual void EmitWin64EHStartProc(const MCSymbol *Symbol);
|
||||
virtual void EmitWin64EHEndProc();
|
||||
virtual void EmitWin64EHStartChained();
|
||||
virtual void EmitWin64EHEndChained();
|
||||
virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
|
||||
bool Except);
|
||||
virtual void EmitWin64EHHandlerData();
|
||||
virtual void EmitWin64EHPushReg(unsigned Register);
|
||||
virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset);
|
||||
virtual void EmitWin64EHAllocStack(unsigned Size);
|
||||
virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset);
|
||||
virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset);
|
||||
virtual void EmitWin64EHPushFrame(bool Code);
|
||||
virtual void EmitWin64EHEndProlog();
|
||||
|
||||
/// EmitInstruction - Emit the given @p Instruction into the current
|
||||
/// section.
|
||||
virtual void EmitInstruction(const MCInst &Inst) = 0;
|
||||
|
93
contrib/llvm/include/llvm/MC/MCWin64EH.h
Normal file
93
contrib/llvm/include/llvm/MC/MCWin64EH.h
Normal file
@ -0,0 +1,93 @@
|
||||
//===- MCWin64EH.h - Machine Code Win64 EH support --------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains declarations to support the Win64 Exception Handling
|
||||
// scheme in MC.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_MC_MCWIN64EH_H
|
||||
#define LLVM_MC_MCWIN64EH_H
|
||||
|
||||
#include "llvm/Support/Win64EH.h"
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class StringRef;
|
||||
class MCStreamer;
|
||||
class MCSymbol;
|
||||
|
||||
class MCWin64EHInstruction {
|
||||
public:
|
||||
typedef Win64EH::UnwindOpcodes OpType;
|
||||
private:
|
||||
OpType Operation;
|
||||
MCSymbol *Label;
|
||||
unsigned Offset;
|
||||
unsigned Register;
|
||||
public:
|
||||
MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg)
|
||||
: Operation(Op), Label(L), Offset(0), Register(Reg) {
|
||||
assert(Op == Win64EH::UOP_PushNonVol);
|
||||
}
|
||||
MCWin64EHInstruction(MCSymbol *L, unsigned Size)
|
||||
: Operation(Size>128 ? Win64EH::UOP_AllocLarge : Win64EH::UOP_AllocSmall),
|
||||
Label(L), Offset(Size) { }
|
||||
MCWin64EHInstruction(OpType Op, MCSymbol *L, unsigned Reg, unsigned Off)
|
||||
: Operation(Op), Label(L), Offset(Off), Register(Reg) {
|
||||
assert(Op == Win64EH::UOP_SetFPReg ||
|
||||
Op == Win64EH::UOP_SaveNonVol ||
|
||||
Op == Win64EH::UOP_SaveNonVolBig ||
|
||||
Op == Win64EH::UOP_SaveXMM128 ||
|
||||
Op == Win64EH::UOP_SaveXMM128Big);
|
||||
}
|
||||
MCWin64EHInstruction(OpType Op, MCSymbol *L, bool Code)
|
||||
: Operation(Op), Label(L), Offset(Code ? 1 : 0) {
|
||||
assert(Op == Win64EH::UOP_PushMachFrame);
|
||||
}
|
||||
OpType getOperation() const { return Operation; }
|
||||
MCSymbol *getLabel() const { return Label; }
|
||||
unsigned getOffset() const { return Offset; }
|
||||
unsigned getSize() const { return Offset; }
|
||||
unsigned getRegister() const { return Register; }
|
||||
bool isPushCodeFrame() const { return Offset == 1; }
|
||||
};
|
||||
|
||||
struct MCWin64EHUnwindInfo {
|
||||
MCWin64EHUnwindInfo() : Begin(0), End(0), ExceptionHandler(0),
|
||||
Function(0), PrologEnd(0), Symbol(0),
|
||||
HandlesUnwind(false), HandlesExceptions(false),
|
||||
LastFrameInst(-1), ChainedParent(0),
|
||||
Instructions() {}
|
||||
MCSymbol *Begin;
|
||||
MCSymbol *End;
|
||||
const MCSymbol *ExceptionHandler;
|
||||
const MCSymbol *Function;
|
||||
MCSymbol *PrologEnd;
|
||||
MCSymbol *Symbol;
|
||||
bool HandlesUnwind;
|
||||
bool HandlesExceptions;
|
||||
int LastFrameInst;
|
||||
MCWin64EHUnwindInfo *ChainedParent;
|
||||
std::vector<MCWin64EHInstruction> Instructions;
|
||||
};
|
||||
|
||||
class MCWin64EHUnwindEmitter {
|
||||
public:
|
||||
static StringRef GetSectionSuffix(const MCSymbol *func);
|
||||
//
|
||||
// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
|
||||
//
|
||||
static void Emit(MCStreamer &streamer);
|
||||
static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info);
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
@ -34,7 +34,7 @@ template<typename ValueSubClass, typename ItemParentClass>
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// MDString - a single uniqued string.
|
||||
/// These are used to efficiently contain a byte sequence for metadata.
|
||||
/// MDString is always unnamd.
|
||||
/// MDString is always unnamed.
|
||||
class MDString : public Value {
|
||||
MDString(const MDString &); // DO NOT IMPLEMENT
|
||||
|
||||
|
@ -186,28 +186,46 @@ class ConcreteOperator : public SuperClass {
|
||||
};
|
||||
|
||||
class AddOperator
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {};
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
|
||||
~AddOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class SubOperator
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {};
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
|
||||
~SubOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class MulOperator
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {};
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
|
||||
~MulOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class ShlOperator
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {};
|
||||
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
|
||||
~ShlOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
|
||||
|
||||
class SDivOperator
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {};
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
|
||||
~SDivOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class UDivOperator
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {};
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {
|
||||
~UDivOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class AShrOperator
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {};
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
|
||||
~AShrOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
class LShrOperator
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {};
|
||||
: public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
|
||||
~LShrOperator(); // DO NOT IMPLEMENT
|
||||
};
|
||||
|
||||
|
||||
|
||||
class GEPOperator
|
||||
: public ConcreteOperator<Operator, Instruction::GetElementPtr> {
|
||||
~GEPOperator(); // DO NOT IMPLEMENT
|
||||
|
||||
enum {
|
||||
IsInBounds = (1 << 0)
|
||||
};
|
||||
|
50
contrib/llvm/include/llvm/Support/BranchProbability.h
Normal file
50
contrib/llvm/include/llvm/Support/BranchProbability.h
Normal file
@ -0,0 +1,50 @@
|
||||
//===- BranchProbability.h - Branch Probability Analysis --------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Definition of BranchProbability shared by IR and Machine Instructions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H
|
||||
#define LLVM_SUPPORT_BRANCHPROBABILITY_H
|
||||
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class raw_ostream;
|
||||
class BranchProbabilityInfo;
|
||||
class MachineBranchProbabilityInfo;
|
||||
class MachineBasicBlock;
|
||||
|
||||
// This class represents Branch Probability as a non-negative fraction.
|
||||
class BranchProbability {
|
||||
friend class BranchProbabilityInfo;
|
||||
friend class MachineBranchProbabilityInfo;
|
||||
friend class MachineBasicBlock;
|
||||
|
||||
// Numerator
|
||||
uint32_t N;
|
||||
|
||||
// Denominator
|
||||
uint32_t D;
|
||||
|
||||
BranchProbability(uint32_t n, uint32_t d);
|
||||
|
||||
public:
|
||||
raw_ostream &print(raw_ostream &OS) const;
|
||||
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -23,8 +23,6 @@ namespace llvm {
|
||||
// isa<x> Support Templates
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
template<typename FromCl> struct isa_impl_cl;
|
||||
|
||||
// Define a template that can be specialized by smart pointers to reflect the
|
||||
// fact that they are automatically dereferenced, and are not involved with the
|
||||
// template selection process... the default implementation is a noop.
|
||||
@ -43,12 +41,9 @@ template<typename From> struct simplify_type<const From> {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// isa<X> - Return true if the parameter to the template is an instance of the
|
||||
// template type argument. Used like this:
|
||||
//
|
||||
// if (isa<Type*>(myVal)) { ... }
|
||||
//
|
||||
// The core of the implementation of isa<X> is here; To and From should be
|
||||
// the names of classes. This template can be specialized to customize the
|
||||
// implementation of isa<> without rewriting it from scratch.
|
||||
template <typename To, typename From>
|
||||
struct isa_impl {
|
||||
static inline bool doit(const From &Val) {
|
||||
@ -56,66 +51,63 @@ struct isa_impl {
|
||||
}
|
||||
};
|
||||
|
||||
template<typename To, typename From, typename SimpleType>
|
||||
template <typename To, typename From> struct isa_impl_cl {
|
||||
static inline bool doit(const From &Val) {
|
||||
return isa_impl<To, From>::doit(Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename To, typename From> struct isa_impl_cl<To, const From> {
|
||||
static inline bool doit(const From &Val) {
|
||||
return isa_impl<To, From>::doit(Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename To, typename From> struct isa_impl_cl<To, From*> {
|
||||
static inline bool doit(const From *Val) {
|
||||
return isa_impl<To, From>::doit(*Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename To, typename From> struct isa_impl_cl<To, const From*> {
|
||||
static inline bool doit(const From *Val) {
|
||||
return isa_impl<To, From>::doit(*Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename To, typename From> struct isa_impl_cl<To, const From*const> {
|
||||
static inline bool doit(const From *Val) {
|
||||
return isa_impl<To, From>::doit(*Val);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename To, typename From, typename SimpleFrom>
|
||||
struct isa_impl_wrap {
|
||||
// When From != SimplifiedType, we can simplify the type some more by using
|
||||
// the simplify_type template.
|
||||
static bool doit(const From &Val) {
|
||||
return isa_impl_cl<const SimpleType>::template
|
||||
isa<To>(simplify_type<const From>::getSimplifiedValue(Val));
|
||||
return isa_impl_wrap<To, SimpleFrom,
|
||||
typename simplify_type<SimpleFrom>::SimpleType>::doit(
|
||||
simplify_type<From>::getSimplifiedValue(Val));
|
||||
}
|
||||
};
|
||||
|
||||
template<typename To, typename FromTy>
|
||||
struct isa_impl_wrap<To, const FromTy, const FromTy> {
|
||||
struct isa_impl_wrap<To, FromTy, FromTy> {
|
||||
// When From == SimpleType, we are as simple as we are going to get.
|
||||
static bool doit(const FromTy &Val) {
|
||||
return isa_impl<To,FromTy>::doit(Val);
|
||||
return isa_impl_cl<To,FromTy>::doit(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// isa_impl_cl - Use class partial specialization to transform types to a single
|
||||
// canonical form for isa_impl.
|
||||
// isa<X> - Return true if the parameter to the template is an instance of the
|
||||
// template type argument. Used like this:
|
||||
//
|
||||
// if (isa<Type>(myVal)) { ... }
|
||||
//
|
||||
template<typename FromCl>
|
||||
struct isa_impl_cl {
|
||||
template<class ToCl>
|
||||
static bool isa(const FromCl &Val) {
|
||||
return isa_impl_wrap<ToCl,const FromCl,
|
||||
typename simplify_type<const FromCl>::SimpleType>::doit(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization used to strip const qualifiers off of the FromCl type...
|
||||
template<typename FromCl>
|
||||
struct isa_impl_cl<const FromCl> {
|
||||
template<class ToCl>
|
||||
static bool isa(const FromCl &Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Define pointer traits in terms of base traits...
|
||||
template<class FromCl>
|
||||
struct isa_impl_cl<FromCl*> {
|
||||
template<class ToCl>
|
||||
static bool isa(FromCl *Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(*Val);
|
||||
}
|
||||
};
|
||||
|
||||
// Define reference traits in terms of base traits...
|
||||
template<class FromCl>
|
||||
struct isa_impl_cl<FromCl&> {
|
||||
template<class ToCl>
|
||||
static bool isa(FromCl &Val) {
|
||||
return isa_impl_cl<FromCl>::template isa<ToCl>(&Val);
|
||||
}
|
||||
};
|
||||
|
||||
template <class X, class Y>
|
||||
inline bool isa(const Y &Val) {
|
||||
return isa_impl_cl<Y>::template isa<X>(Val);
|
||||
return isa_impl_wrap<X, Y, typename simplify_type<Y>::SimpleType>::doit(Val);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -186,8 +186,13 @@ class CrashRecoveryContextCleanupRegistrar {
|
||||
}
|
||||
|
||||
~CrashRecoveryContextCleanupRegistrar() {
|
||||
unregister();
|
||||
}
|
||||
|
||||
void unregister() {
|
||||
if (cleanup && !cleanup->cleanupFired)
|
||||
cleanup->getContext()->unregisterCleanup(cleanup);
|
||||
cleanup->getContext()->unregisterCleanup(cleanup);
|
||||
cleanup = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ enum dwarf_constants {
|
||||
DW_AT_APPLE_property_getter = 0x3fe9,
|
||||
DW_AT_APPLE_property_setter = 0x3fea,
|
||||
DW_AT_APPLE_property_attribute = 0x3feb,
|
||||
DW_AT_APPLE_objc_complete_type = 0x3fec,
|
||||
|
||||
// Attribute form encodings
|
||||
DW_FORM_addr = 0x01,
|
||||
|
@ -80,6 +80,7 @@ class IRBuilderBase {
|
||||
void SetInsertPoint(Instruction *I) {
|
||||
BB = I->getParent();
|
||||
InsertPt = I;
|
||||
SetCurrentDebugLocation(I->getDebugLoc());
|
||||
}
|
||||
|
||||
/// SetInsertPoint - This specifies that created instructions should be
|
||||
@ -106,6 +107,10 @@ class IRBuilderBase {
|
||||
I->setDebugLoc(CurDbgLocation);
|
||||
}
|
||||
|
||||
/// getCurrentFunctionReturnType - Get the return type of the current function
|
||||
/// that we're emitting into.
|
||||
const Type *getCurrentFunctionReturnType() const;
|
||||
|
||||
/// InsertPoint - A saved insertion point.
|
||||
class InsertPoint {
|
||||
BasicBlock *Block;
|
||||
@ -194,6 +199,7 @@ class IRBuilderBase {
|
||||
return ConstantInt::get(getInt64Ty(), C);
|
||||
}
|
||||
|
||||
/// getInt - Get a constant integer value.
|
||||
ConstantInt *getInt(const APInt &AI) {
|
||||
return ConstantInt::get(Context, AI);
|
||||
}
|
||||
@ -246,10 +252,10 @@ class IRBuilderBase {
|
||||
return Type::getInt8PtrTy(Context, AddrSpace);
|
||||
}
|
||||
|
||||
/// getCurrentFunctionReturnType - Get the return type of the current function
|
||||
/// that we're emitting into.
|
||||
const Type *getCurrentFunctionReturnType() const;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Intrinsic creation methods
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
/// CreateMemSet - Create and insert a memset to the specified pointer and the
|
||||
/// specified value. If the pointer isn't an i8*, it will be converted. If a
|
||||
/// TBAA tag is specified, it will be added to the instruction.
|
||||
@ -282,6 +288,15 @@ class IRBuilderBase {
|
||||
|
||||
CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
|
||||
bool isVolatile = false, MDNode *TBAATag = 0);
|
||||
|
||||
/// CreateLifetimeStart - Create a lifetime.start intrinsic. If the pointer
|
||||
/// isn't i8* it will be converted.
|
||||
CallInst *CreateLifetimeStart(Value *Ptr, ConstantInt *Size = 0);
|
||||
|
||||
/// CreateLifetimeEnd - Create a lifetime.end intrinsic. If the pointer isn't
|
||||
/// i8* it will be converted.
|
||||
CallInst *CreateLifetimeEnd(Value *Ptr, ConstantInt *Size = 0);
|
||||
|
||||
private:
|
||||
Value *getCastedInt8PtrValue(Value *Ptr);
|
||||
};
|
||||
@ -324,6 +339,7 @@ class IRBuilder : public IRBuilderBase, public Inserter {
|
||||
explicit IRBuilder(Instruction *IP)
|
||||
: IRBuilderBase(IP->getContext()), Folder() {
|
||||
SetInsertPoint(IP);
|
||||
SetCurrentDebugLocation(IP->getDebugLoc());
|
||||
}
|
||||
|
||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F)
|
||||
|
@ -81,7 +81,7 @@ class MemoryBuffer {
|
||||
bool RequiresNullTerminator = true);
|
||||
|
||||
/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
|
||||
/// that InputData must be null terminated.
|
||||
/// that InputData must be null terminated if RequiresNullTerminator is true.
|
||||
static MemoryBuffer *getMemBuffer(StringRef InputData,
|
||||
StringRef BufferName = "",
|
||||
bool RequiresNullTerminator = true);
|
||||
|
322
contrib/llvm/include/llvm/Support/PassManagerBuilder.h
Normal file
322
contrib/llvm/include/llvm/Support/PassManagerBuilder.h
Normal file
@ -0,0 +1,322 @@
|
||||
//===-- llvm/Support/PassManagerBuilder.h - Build Standard Pass -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the PassManagerBuilder class, which is used to set up a
|
||||
// "standard" optimization sequence suitable for languages like C and C++.
|
||||
//
|
||||
// These are implemented as inline functions so that we do not have to worry
|
||||
// about link issues.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_PASSMANAGERBUILDER_H
|
||||
#define LLVM_SUPPORT_PASSMANAGERBUILDER_H
|
||||
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/DefaultPasses.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// PassManagerBuilder - This class is used to set up a standard optimization
|
||||
/// sequence for languages like C and C++, allowing some APIs to customize the
|
||||
/// pass sequence in various ways. A simple example of using it would be:
|
||||
///
|
||||
/// PassManagerBuilder Builder;
|
||||
/// Builder.OptLevel = 2;
|
||||
/// Builder.populateFunctionPassManager(FPM);
|
||||
/// Builder.populateModulePassManager(MPM);
|
||||
///
|
||||
/// In addition to setting up the basic passes, PassManagerBuilder allows
|
||||
/// frontends to vend a plugin API, where plugins are allowed to add extensions
|
||||
/// to the default pass manager. They do this by specifying where in the pass
|
||||
/// pipeline they want to be added, along with a callback function that adds
|
||||
/// the pass(es). For example, a plugin that wanted to add a loop optimization
|
||||
/// could do something like this:
|
||||
///
|
||||
/// static void addMyLoopPass(const PMBuilder &Builder, PassManagerBase &PM) {
|
||||
/// if (Builder.getOptLevel() > 2 && Builder.getOptSizeLevel() == 0)
|
||||
/// PM.add(createMyAwesomePass());
|
||||
/// }
|
||||
/// ...
|
||||
/// Builder.addExtension(PassManagerBuilder::EP_LoopOptimizerEnd,
|
||||
/// addMyLoopPass);
|
||||
/// ...
|
||||
class PassManagerBuilder {
|
||||
public:
|
||||
|
||||
/// Extensions are passed the builder itself (so they can see how it is
|
||||
/// configured) as well as the pass manager to add stuff to.
|
||||
typedef void (*ExtensionFn)(const PassManagerBuilder &Builder,
|
||||
PassManagerBase &PM);
|
||||
enum ExtensionPointTy {
|
||||
/// EP_EarlyAsPossible - This extension point allows adding passes before
|
||||
/// any other transformations, allowing them to see the code as it is coming
|
||||
/// out of the frontend.
|
||||
EP_EarlyAsPossible,
|
||||
|
||||
/// EP_LoopOptimizerEnd - This extension point allows adding loop passes to
|
||||
/// the end of the loop optimizer.
|
||||
EP_LoopOptimizerEnd
|
||||
};
|
||||
|
||||
/// The Optimization Level - Specify the basic optimization level.
|
||||
/// 0 = -O0, 1 = -O1, 2 = -O2, 3 = -O3
|
||||
unsigned OptLevel;
|
||||
|
||||
/// SizeLevel - How much we're optimizing for size.
|
||||
/// 0 = none, 1 = -Os, 2 = -Oz
|
||||
unsigned SizeLevel;
|
||||
|
||||
/// LibraryInfo - Specifies information about the runtime library for the
|
||||
/// optimizer. If this is non-null, it is added to both the function and
|
||||
/// per-module pass pipeline.
|
||||
TargetLibraryInfo *LibraryInfo;
|
||||
|
||||
/// Inliner - Specifies the inliner to use. If this is non-null, it is
|
||||
/// added to the per-module passes.
|
||||
Pass *Inliner;
|
||||
|
||||
bool DisableSimplifyLibCalls;
|
||||
bool DisableUnitAtATime;
|
||||
bool DisableUnrollLoops;
|
||||
|
||||
private:
|
||||
/// ExtensionList - This is list of all of the extensions that are registered.
|
||||
std::vector<std::pair<ExtensionPointTy, ExtensionFn> > Extensions;
|
||||
|
||||
public:
|
||||
PassManagerBuilder() {
|
||||
OptLevel = 2;
|
||||
SizeLevel = 0;
|
||||
LibraryInfo = 0;
|
||||
Inliner = 0;
|
||||
DisableSimplifyLibCalls = false;
|
||||
DisableUnitAtATime = false;
|
||||
DisableUnrollLoops = false;
|
||||
}
|
||||
|
||||
~PassManagerBuilder() {
|
||||
delete LibraryInfo;
|
||||
delete Inliner;
|
||||
}
|
||||
|
||||
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn) {
|
||||
Extensions.push_back(std::make_pair(Ty, Fn));
|
||||
}
|
||||
|
||||
private:
|
||||
void addExtensionsToPM(ExtensionPointTy ETy, PassManagerBase &PM) const {
|
||||
for (unsigned i = 0, e = Extensions.size(); i != e; ++i)
|
||||
if (Extensions[i].first == ETy)
|
||||
Extensions[i].second(*this, PM);
|
||||
}
|
||||
|
||||
void addInitialAliasAnalysisPasses(PassManagerBase &PM) const {
|
||||
// Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
|
||||
// BasicAliasAnalysis wins if they disagree. This is intended to help
|
||||
// support "obvious" type-punning idioms.
|
||||
PM.add(createTypeBasedAliasAnalysisPass());
|
||||
PM.add(createBasicAliasAnalysisPass());
|
||||
}
|
||||
public:
|
||||
|
||||
/// populateFunctionPassManager - This fills in the function pass manager,
|
||||
/// which is expected to be run on each function immediately as it is
|
||||
/// generated. The idea is to reduce the size of the IR in memory.
|
||||
void populateFunctionPassManager(FunctionPassManager &FPM) {
|
||||
addExtensionsToPM(EP_EarlyAsPossible, FPM);
|
||||
|
||||
// Add LibraryInfo if we have some.
|
||||
if (LibraryInfo) FPM.add(new TargetLibraryInfo(*LibraryInfo));
|
||||
|
||||
if (OptLevel == 0) return;
|
||||
|
||||
addInitialAliasAnalysisPasses(FPM);
|
||||
|
||||
FPM.add(createCFGSimplificationPass());
|
||||
FPM.add(createScalarReplAggregatesPass());
|
||||
FPM.add(createEarlyCSEPass());
|
||||
}
|
||||
|
||||
/// populateModulePassManager - This sets up the primary pass manager.
|
||||
void populateModulePassManager(PassManagerBase &MPM) {
|
||||
// If all optimizations are disabled, just run the always-inline pass.
|
||||
if (OptLevel == 0) {
|
||||
if (Inliner) {
|
||||
MPM.add(Inliner);
|
||||
Inliner = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Add LibraryInfo if we have some.
|
||||
if (LibraryInfo) MPM.add(new TargetLibraryInfo(*LibraryInfo));
|
||||
|
||||
addInitialAliasAnalysisPasses(MPM);
|
||||
|
||||
if (!DisableUnitAtATime) {
|
||||
MPM.add(createGlobalOptimizerPass()); // Optimize out global vars
|
||||
|
||||
MPM.add(createIPSCCPPass()); // IP SCCP
|
||||
MPM.add(createDeadArgEliminationPass()); // Dead argument elimination
|
||||
|
||||
MPM.add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
||||
MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
||||
}
|
||||
|
||||
// Start of CallGraph SCC passes.
|
||||
if (!DisableUnitAtATime)
|
||||
MPM.add(createPruneEHPass()); // Remove dead EH info
|
||||
if (Inliner) {
|
||||
MPM.add(Inliner);
|
||||
Inliner = 0;
|
||||
}
|
||||
if (!DisableUnitAtATime)
|
||||
MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs
|
||||
if (OptLevel > 2)
|
||||
MPM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
|
||||
|
||||
// Start of function pass.
|
||||
// Break up aggregate allocas, using SSAUpdater.
|
||||
MPM.add(createScalarReplAggregatesPass(-1, false));
|
||||
MPM.add(createEarlyCSEPass()); // Catch trivial redundancies
|
||||
if (!DisableSimplifyLibCalls)
|
||||
MPM.add(createSimplifyLibCallsPass()); // Library Call Optimizations
|
||||
MPM.add(createJumpThreadingPass()); // Thread jumps.
|
||||
MPM.add(createCorrelatedValuePropagationPass()); // Propagate conditionals
|
||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
MPM.add(createInstructionCombiningPass()); // Combine silly seq's
|
||||
|
||||
MPM.add(createTailCallEliminationPass()); // Eliminate tail calls
|
||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
MPM.add(createReassociatePass()); // Reassociate expressions
|
||||
MPM.add(createLoopRotatePass()); // Rotate Loop
|
||||
MPM.add(createLICMPass()); // Hoist loop invariants
|
||||
MPM.add(createLoopUnswitchPass(SizeLevel || OptLevel < 3));
|
||||
MPM.add(createInstructionCombiningPass());
|
||||
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
|
||||
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
|
||||
MPM.add(createLoopDeletionPass()); // Delete dead loops
|
||||
if (!DisableUnrollLoops)
|
||||
MPM.add(createLoopUnrollPass()); // Unroll small loops
|
||||
addExtensionsToPM(EP_LoopOptimizerEnd, MPM);
|
||||
|
||||
if (OptLevel > 1)
|
||||
MPM.add(createGVNPass()); // Remove redundancies
|
||||
MPM.add(createMemCpyOptPass()); // Remove memcpy / form memset
|
||||
MPM.add(createSCCPPass()); // Constant prop with SCCP
|
||||
|
||||
// Run instcombine after redundancy elimination to exploit opportunities
|
||||
// opened up by them.
|
||||
MPM.add(createInstructionCombiningPass());
|
||||
MPM.add(createJumpThreadingPass()); // Thread jumps
|
||||
MPM.add(createCorrelatedValuePropagationPass());
|
||||
MPM.add(createDeadStoreEliminationPass()); // Delete dead stores
|
||||
MPM.add(createAggressiveDCEPass()); // Delete dead instructions
|
||||
MPM.add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
MPM.add(createInstructionCombiningPass()); // Clean up after everything.
|
||||
|
||||
if (!DisableUnitAtATime) {
|
||||
MPM.add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
|
||||
MPM.add(createDeadTypeEliminationPass()); // Eliminate dead types
|
||||
|
||||
// GlobalOpt already deletes dead functions and globals, at -O3 try a
|
||||
// late pass of GlobalDCE. It is capable of deleting dead cycles.
|
||||
if (OptLevel > 2)
|
||||
MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
|
||||
|
||||
if (OptLevel > 1)
|
||||
MPM.add(createConstantMergePass()); // Merge dup global constants
|
||||
}
|
||||
}
|
||||
|
||||
void populateLTOPassManager(PassManagerBase &PM, bool Internalize,
|
||||
bool RunInliner) {
|
||||
// Provide AliasAnalysis services for optimizations.
|
||||
addInitialAliasAnalysisPasses(PM);
|
||||
|
||||
// Now that composite has been compiled, scan through the module, looking
|
||||
// for a main function. If main is defined, mark all other functions
|
||||
// internal.
|
||||
if (Internalize)
|
||||
PM.add(createInternalizePass(true));
|
||||
|
||||
// Propagate constants at call sites into the functions they call. This
|
||||
// opens opportunities for globalopt (and inlining) by substituting function
|
||||
// pointers passed as arguments to direct uses of functions.
|
||||
PM.add(createIPSCCPPass());
|
||||
|
||||
// Now that we internalized some globals, see if we can hack on them!
|
||||
PM.add(createGlobalOptimizerPass());
|
||||
|
||||
// Linking modules together can lead to duplicated global constants, only
|
||||
// keep one copy of each constant.
|
||||
PM.add(createConstantMergePass());
|
||||
|
||||
// Remove unused arguments from functions.
|
||||
PM.add(createDeadArgEliminationPass());
|
||||
|
||||
// Reduce the code after globalopt and ipsccp. Both can open up significant
|
||||
// simplification opportunities, and both can propagate functions through
|
||||
// function pointers. When this happens, we often have to resolve varargs
|
||||
// calls, etc, so let instcombine do this.
|
||||
PM.add(createInstructionCombiningPass());
|
||||
|
||||
// Inline small functions
|
||||
if (RunInliner)
|
||||
PM.add(createFunctionInliningPass());
|
||||
|
||||
PM.add(createPruneEHPass()); // Remove dead EH info.
|
||||
|
||||
// Optimize globals again if we ran the inliner.
|
||||
if (RunInliner)
|
||||
PM.add(createGlobalOptimizerPass());
|
||||
PM.add(createGlobalDCEPass()); // Remove dead functions.
|
||||
|
||||
// If we didn't decide to inline a function, check to see if we can
|
||||
// transform it to pass arguments by value instead of by reference.
|
||||
PM.add(createArgumentPromotionPass());
|
||||
|
||||
// The IPO passes may leave cruft around. Clean up after them.
|
||||
PM.add(createInstructionCombiningPass());
|
||||
PM.add(createJumpThreadingPass());
|
||||
// Break up allocas
|
||||
PM.add(createScalarReplAggregatesPass());
|
||||
|
||||
// Run a few AA driven optimizations here and now, to cleanup the code.
|
||||
PM.add(createFunctionAttrsPass()); // Add nocapture.
|
||||
PM.add(createGlobalsModRefPass()); // IP alias analysis.
|
||||
|
||||
PM.add(createLICMPass()); // Hoist loop invariants.
|
||||
PM.add(createGVNPass()); // Remove redundancies.
|
||||
PM.add(createMemCpyOptPass()); // Remove dead memcpys.
|
||||
// Nuke dead stores.
|
||||
PM.add(createDeadStoreEliminationPass());
|
||||
|
||||
// Cleanup and simplify the code after the scalar optimizations.
|
||||
PM.add(createInstructionCombiningPass());
|
||||
|
||||
PM.add(createJumpThreadingPass());
|
||||
|
||||
// Delete basic blocks, which optimization passes may have killed.
|
||||
PM.add(createCFGSimplificationPass());
|
||||
|
||||
// Now that we have optimized the program, discard unreachable functions.
|
||||
PM.add(createGlobalDCEPass());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end namespace llvm
|
||||
#endif
|
@ -694,6 +694,99 @@ inline brc_match<Cond_t> m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F) {
|
||||
return brc_match<Cond_t>(C, T, F);
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Matchers for max/min idioms, eg: "select (sgt x, y), x, y" -> smax(x,y).
|
||||
//
|
||||
|
||||
template<typename LHS_t, typename RHS_t, typename Pred_t>
|
||||
struct MaxMin_match {
|
||||
LHS_t L;
|
||||
RHS_t R;
|
||||
|
||||
MaxMin_match(const LHS_t &LHS, const RHS_t &RHS)
|
||||
: L(LHS), R(RHS) {}
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V) {
|
||||
// Look for "(x pred y) ? x : y" or "(x pred y) ? y : x".
|
||||
SelectInst *SI = dyn_cast<SelectInst>(V);
|
||||
if (!SI)
|
||||
return false;
|
||||
ICmpInst *Cmp = dyn_cast<ICmpInst>(SI->getCondition());
|
||||
if (!Cmp)
|
||||
return false;
|
||||
// At this point we have a select conditioned on a comparison. Check that
|
||||
// it is the values returned by the select that are being compared.
|
||||
Value *TrueVal = SI->getTrueValue();
|
||||
Value *FalseVal = SI->getFalseValue();
|
||||
Value *LHS = Cmp->getOperand(0);
|
||||
Value *RHS = Cmp->getOperand(1);
|
||||
if ((TrueVal != LHS || FalseVal != RHS) &&
|
||||
(TrueVal != RHS || FalseVal != LHS))
|
||||
return false;
|
||||
ICmpInst::Predicate Pred = LHS == TrueVal ?
|
||||
Cmp->getPredicate() : Cmp->getSwappedPredicate();
|
||||
// Does "(x pred y) ? x : y" represent the desired max/min operation?
|
||||
if (!Pred_t::match(Pred))
|
||||
return false;
|
||||
// It does! Bind the operands.
|
||||
return L.match(LHS) && R.match(RHS);
|
||||
}
|
||||
};
|
||||
|
||||
/// smax_pred_ty - Helper class for identifying signed max predicates.
|
||||
struct smax_pred_ty {
|
||||
static bool match(ICmpInst::Predicate Pred) {
|
||||
return Pred == CmpInst::ICMP_SGT || Pred == CmpInst::ICMP_SGE;
|
||||
}
|
||||
};
|
||||
|
||||
/// smin_pred_ty - Helper class for identifying signed min predicates.
|
||||
struct smin_pred_ty {
|
||||
static bool match(ICmpInst::Predicate Pred) {
|
||||
return Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_SLE;
|
||||
}
|
||||
};
|
||||
|
||||
/// umax_pred_ty - Helper class for identifying unsigned max predicates.
|
||||
struct umax_pred_ty {
|
||||
static bool match(ICmpInst::Predicate Pred) {
|
||||
return Pred == CmpInst::ICMP_UGT || Pred == CmpInst::ICMP_UGE;
|
||||
}
|
||||
};
|
||||
|
||||
/// umin_pred_ty - Helper class for identifying unsigned min predicates.
|
||||
struct umin_pred_ty {
|
||||
static bool match(ICmpInst::Predicate Pred) {
|
||||
return Pred == CmpInst::ICMP_ULT || Pred == CmpInst::ICMP_ULE;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline MaxMin_match<LHS, RHS, smax_pred_ty>
|
||||
m_SMax(const LHS &L, const RHS &R) {
|
||||
return MaxMin_match<LHS, RHS, smax_pred_ty>(L, R);
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline MaxMin_match<LHS, RHS, smin_pred_ty>
|
||||
m_SMin(const LHS &L, const RHS &R) {
|
||||
return MaxMin_match<LHS, RHS, smin_pred_ty>(L, R);
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline MaxMin_match<LHS, RHS, umax_pred_ty>
|
||||
m_UMax(const LHS &L, const RHS &R) {
|
||||
return MaxMin_match<LHS, RHS, umax_pred_ty>(L, R);
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline MaxMin_match<LHS, RHS, umin_pred_ty>
|
||||
m_UMin(const LHS &L, const RHS &R) {
|
||||
return MaxMin_match<LHS, RHS, umin_pred_ty>(L, R);
|
||||
}
|
||||
|
||||
} // end namespace PatternMatch
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -85,8 +85,9 @@ namespace sys {
|
||||
/// This function waits for the program to exit. This function will block
|
||||
/// the current program until the invoked program exits.
|
||||
/// @returns an integer result code indicating the status of the program.
|
||||
/// A zero or positive value indicates the result code of the program. A
|
||||
/// negative value is the signal number on which it terminated.
|
||||
/// A zero or positive value indicates the result code of the program.
|
||||
/// -1 indicates failure to execute
|
||||
/// -2 indicates a crash during execution or timeout
|
||||
/// @see Execute
|
||||
/// @brief Waits for the program to exit.
|
||||
int Wait
|
||||
|
@ -106,7 +106,9 @@ class SourceMgr {
|
||||
/// AddIncludeFile - Search for a file with the specified name in the current
|
||||
/// directory or in one of the IncludeDirs. If no file is found, this returns
|
||||
/// ~0, otherwise it returns the buffer ID of the stacked file.
|
||||
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc);
|
||||
/// The full path to the included file can be found in IncludedFile.
|
||||
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc,
|
||||
std::string &IncludedFile);
|
||||
|
||||
/// FindBufferContainingLoc - Return the ID of the buffer containing the
|
||||
/// specified location, returning -1 if not found.
|
||||
|
@ -1,244 +0,0 @@
|
||||
//===-- llvm/Support/StandardPasses.h - Standard pass lists -----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines utility functions for creating a "standard" set of
|
||||
// optimization passes, so that compilers and tools which use optimization
|
||||
// passes use the same set of standard passes.
|
||||
//
|
||||
// These are implemented as inline functions so that we do not have to worry
|
||||
// about link issues.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_STANDARDPASSES_H
|
||||
#define LLVM_SUPPORT_STANDARDPASSES_H
|
||||
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
static inline void createStandardAliasAnalysisPasses(PassManagerBase *PM) {
|
||||
// Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
|
||||
// BasicAliasAnalysis wins if they disagree. This is intended to help
|
||||
// support "obvious" type-punning idioms.
|
||||
PM->add(createTypeBasedAliasAnalysisPass());
|
||||
PM->add(createBasicAliasAnalysisPass());
|
||||
}
|
||||
|
||||
/// createStandardFunctionPasses - Add the standard list of function passes to
|
||||
/// the provided pass manager.
|
||||
///
|
||||
/// \arg OptimizationLevel - The optimization level, corresponding to -O0,
|
||||
/// -O1, etc.
|
||||
static inline void createStandardFunctionPasses(PassManagerBase *PM,
|
||||
unsigned OptimizationLevel) {
|
||||
if (OptimizationLevel > 0) {
|
||||
createStandardAliasAnalysisPasses(PM);
|
||||
PM->add(createCFGSimplificationPass());
|
||||
PM->add(createScalarReplAggregatesPass());
|
||||
PM->add(createEarlyCSEPass());
|
||||
}
|
||||
}
|
||||
|
||||
/// createStandardModulePasses - Add the standard list of module passes to the
|
||||
/// provided pass manager.
|
||||
///
|
||||
/// \arg OptimizationLevel - The optimization level, corresponding to -O0,
|
||||
/// -O1, etc.
|
||||
/// \arg OptimizeSize - Whether the transformations should optimize for size.
|
||||
/// \arg UnitAtATime - Allow passes which may make global module changes.
|
||||
/// \arg UnrollLoops - Allow loop unrolling.
|
||||
/// \arg SimplifyLibCalls - Allow library calls to be simplified.
|
||||
/// \arg HaveExceptions - Whether the module may have code using exceptions.
|
||||
/// \arg InliningPass - The inlining pass to use, if any, or null. This will
|
||||
/// always be added, even at -O0.a
|
||||
static inline void createStandardModulePasses(PassManagerBase *PM,
|
||||
unsigned OptimizationLevel,
|
||||
bool OptimizeSize,
|
||||
bool UnitAtATime,
|
||||
bool UnrollLoops,
|
||||
bool SimplifyLibCalls,
|
||||
bool HaveExceptions,
|
||||
Pass *InliningPass) {
|
||||
createStandardAliasAnalysisPasses(PM);
|
||||
|
||||
// If all optimizations are disabled, just run the always-inline pass.
|
||||
if (OptimizationLevel == 0) {
|
||||
if (InliningPass)
|
||||
PM->add(InliningPass);
|
||||
return;
|
||||
}
|
||||
|
||||
if (UnitAtATime) {
|
||||
PM->add(createGlobalOptimizerPass()); // Optimize out global vars
|
||||
|
||||
PM->add(createIPSCCPPass()); // IP SCCP
|
||||
PM->add(createDeadArgEliminationPass()); // Dead argument elimination
|
||||
|
||||
PM->add(createInstructionCombiningPass());// Clean up after IPCP & DAE
|
||||
PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
|
||||
}
|
||||
|
||||
// Start of CallGraph SCC passes.
|
||||
if (UnitAtATime && HaveExceptions)
|
||||
PM->add(createPruneEHPass()); // Remove dead EH info
|
||||
if (InliningPass)
|
||||
PM->add(InliningPass);
|
||||
if (UnitAtATime)
|
||||
PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs
|
||||
if (OptimizationLevel > 2)
|
||||
PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args
|
||||
|
||||
// Start of function pass.
|
||||
// Break up aggregate allocas, using SSAUpdater.
|
||||
PM->add(createScalarReplAggregatesPass(-1, false));
|
||||
PM->add(createEarlyCSEPass()); // Catch trivial redundancies
|
||||
if (SimplifyLibCalls)
|
||||
PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations
|
||||
PM->add(createJumpThreadingPass()); // Thread jumps.
|
||||
PM->add(createCorrelatedValuePropagationPass()); // Propagate conditionals
|
||||
PM->add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
PM->add(createInstructionCombiningPass()); // Combine silly seq's
|
||||
|
||||
PM->add(createTailCallEliminationPass()); // Eliminate tail calls
|
||||
PM->add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
PM->add(createReassociatePass()); // Reassociate expressions
|
||||
PM->add(createLoopRotatePass()); // Rotate Loop
|
||||
PM->add(createLICMPass()); // Hoist loop invariants
|
||||
PM->add(createLoopUnswitchPass(OptimizeSize || OptimizationLevel < 3));
|
||||
PM->add(createInstructionCombiningPass());
|
||||
PM->add(createIndVarSimplifyPass()); // Canonicalize indvars
|
||||
PM->add(createLoopIdiomPass()); // Recognize idioms like memset.
|
||||
PM->add(createLoopDeletionPass()); // Delete dead loops
|
||||
if (UnrollLoops)
|
||||
PM->add(createLoopUnrollPass()); // Unroll small loops
|
||||
if (OptimizationLevel > 1)
|
||||
PM->add(createGVNPass()); // Remove redundancies
|
||||
PM->add(createMemCpyOptPass()); // Remove memcpy / form memset
|
||||
PM->add(createSCCPPass()); // Constant prop with SCCP
|
||||
|
||||
// Run instcombine after redundancy elimination to exploit opportunities
|
||||
// opened up by them.
|
||||
PM->add(createInstructionCombiningPass());
|
||||
PM->add(createJumpThreadingPass()); // Thread jumps
|
||||
PM->add(createCorrelatedValuePropagationPass());
|
||||
PM->add(createDeadStoreEliminationPass()); // Delete dead stores
|
||||
PM->add(createAggressiveDCEPass()); // Delete dead instructions
|
||||
PM->add(createCFGSimplificationPass()); // Merge & remove BBs
|
||||
PM->add(createInstructionCombiningPass()); // Clean up after everything.
|
||||
|
||||
if (UnitAtATime) {
|
||||
PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes
|
||||
PM->add(createDeadTypeEliminationPass()); // Eliminate dead types
|
||||
|
||||
// GlobalOpt already deletes dead functions and globals, at -O3 try a
|
||||
// late pass of GlobalDCE. It is capable of deleting dead cycles.
|
||||
if (OptimizationLevel > 2)
|
||||
PM->add(createGlobalDCEPass()); // Remove dead fns and globals.
|
||||
|
||||
if (OptimizationLevel > 1)
|
||||
PM->add(createConstantMergePass()); // Merge dup global constants
|
||||
}
|
||||
}
|
||||
|
||||
static inline void addOnePass(PassManagerBase *PM, Pass *P, bool AndVerify) {
|
||||
PM->add(P);
|
||||
|
||||
if (AndVerify)
|
||||
PM->add(createVerifierPass());
|
||||
}
|
||||
|
||||
/// createStandardLTOPasses - Add the standard list of module passes suitable
|
||||
/// for link time optimization.
|
||||
///
|
||||
/// Internalize - Run the internalize pass.
|
||||
/// RunInliner - Use a function inlining pass.
|
||||
/// VerifyEach - Run the verifier after each pass.
|
||||
static inline void createStandardLTOPasses(PassManagerBase *PM,
|
||||
bool Internalize,
|
||||
bool RunInliner,
|
||||
bool VerifyEach) {
|
||||
// Provide AliasAnalysis services for optimizations.
|
||||
createStandardAliasAnalysisPasses(PM);
|
||||
|
||||
// Now that composite has been compiled, scan through the module, looking
|
||||
// for a main function. If main is defined, mark all other functions
|
||||
// internal.
|
||||
if (Internalize)
|
||||
addOnePass(PM, createInternalizePass(true), VerifyEach);
|
||||
|
||||
// Propagate constants at call sites into the functions they call. This
|
||||
// opens opportunities for globalopt (and inlining) by substituting function
|
||||
// pointers passed as arguments to direct uses of functions.
|
||||
addOnePass(PM, createIPSCCPPass(), VerifyEach);
|
||||
|
||||
// Now that we internalized some globals, see if we can hack on them!
|
||||
addOnePass(PM, createGlobalOptimizerPass(), VerifyEach);
|
||||
|
||||
// Linking modules together can lead to duplicated global constants, only
|
||||
// keep one copy of each constant...
|
||||
addOnePass(PM, createConstantMergePass(), VerifyEach);
|
||||
|
||||
// Remove unused arguments from functions...
|
||||
addOnePass(PM, createDeadArgEliminationPass(), VerifyEach);
|
||||
|
||||
// Reduce the code after globalopt and ipsccp. Both can open up significant
|
||||
// simplification opportunities, and both can propagate functions through
|
||||
// function pointers. When this happens, we often have to resolve varargs
|
||||
// calls, etc, so let instcombine do this.
|
||||
addOnePass(PM, createInstructionCombiningPass(), VerifyEach);
|
||||
|
||||
// Inline small functions
|
||||
if (RunInliner)
|
||||
addOnePass(PM, createFunctionInliningPass(), VerifyEach);
|
||||
|
||||
addOnePass(PM, createPruneEHPass(), VerifyEach); // Remove dead EH info.
|
||||
// Optimize globals again if we ran the inliner.
|
||||
if (RunInliner)
|
||||
addOnePass(PM, createGlobalOptimizerPass(), VerifyEach);
|
||||
addOnePass(PM, createGlobalDCEPass(), VerifyEach); // Remove dead functions.
|
||||
|
||||
// If we didn't decide to inline a function, check to see if we can
|
||||
// transform it to pass arguments by value instead of by reference.
|
||||
addOnePass(PM, createArgumentPromotionPass(), VerifyEach);
|
||||
|
||||
// The IPO passes may leave cruft around. Clean up after them.
|
||||
addOnePass(PM, createInstructionCombiningPass(), VerifyEach);
|
||||
addOnePass(PM, createJumpThreadingPass(), VerifyEach);
|
||||
// Break up allocas
|
||||
addOnePass(PM, createScalarReplAggregatesPass(), VerifyEach);
|
||||
|
||||
// Run a few AA driven optimizations here and now, to cleanup the code.
|
||||
addOnePass(PM, createFunctionAttrsPass(), VerifyEach); // Add nocapture.
|
||||
addOnePass(PM, createGlobalsModRefPass(), VerifyEach); // IP alias analysis.
|
||||
|
||||
addOnePass(PM, createLICMPass(), VerifyEach); // Hoist loop invariants.
|
||||
addOnePass(PM, createGVNPass(), VerifyEach); // Remove redundancies.
|
||||
addOnePass(PM, createMemCpyOptPass(), VerifyEach); // Remove dead memcpys.
|
||||
// Nuke dead stores.
|
||||
addOnePass(PM, createDeadStoreEliminationPass(), VerifyEach);
|
||||
|
||||
// Cleanup and simplify the code after the scalar optimizations.
|
||||
addOnePass(PM, createInstructionCombiningPass(), VerifyEach);
|
||||
|
||||
addOnePass(PM, createJumpThreadingPass(), VerifyEach);
|
||||
|
||||
// Delete basic blocks, which optimization passes may have killed.
|
||||
addOnePass(PM, createCFGSimplificationPass(), VerifyEach);
|
||||
|
||||
// Now that we have optimized the program, discard unreachable functions.
|
||||
addOnePass(PM, createGlobalDCEPass(), VerifyEach);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
100
contrib/llvm/include/llvm/Support/Win64EH.h
Normal file
100
contrib/llvm/include/llvm/Support/Win64EH.h
Normal file
@ -0,0 +1,100 @@
|
||||
//===-- llvm/Support/Win64EH.h ---Win64 EH Constants-------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains constants and structures used for implementing
|
||||
// exception handling on Win64 platforms. For more information, see
|
||||
// http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_WIN64EH_H
|
||||
#define LLVM_SUPPORT_WIN64EH_H
|
||||
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace Win64EH {
|
||||
|
||||
/// UnwindOpcodes - Enumeration whose values specify a single operation in
|
||||
/// the prolog of a function.
|
||||
enum UnwindOpcodes {
|
||||
UOP_PushNonVol = 0,
|
||||
UOP_AllocLarge,
|
||||
UOP_AllocSmall,
|
||||
UOP_SetFPReg,
|
||||
UOP_SaveNonVol,
|
||||
UOP_SaveNonVolBig,
|
||||
UOP_SaveXMM128 = 8,
|
||||
UOP_SaveXMM128Big,
|
||||
UOP_PushMachFrame
|
||||
};
|
||||
|
||||
/// UnwindCode - This union describes a single operation in a function prolog,
|
||||
/// or part thereof.
|
||||
union UnwindCode {
|
||||
struct {
|
||||
uint8_t codeOffset;
|
||||
uint8_t unwindOp:4,
|
||||
opInfo:4;
|
||||
} u;
|
||||
uint16_t frameOffset;
|
||||
};
|
||||
|
||||
enum {
|
||||
/// UNW_ExceptionHandler - Specifies that this function has an exception
|
||||
/// handler.
|
||||
UNW_ExceptionHandler = 0x01,
|
||||
/// UNW_TerminateHandler - Specifies that this function has a termination
|
||||
/// handler.
|
||||
UNW_TerminateHandler = 0x02,
|
||||
/// UNW_ChainInfo - Specifies that this UnwindInfo structure is chained to
|
||||
/// another one.
|
||||
UNW_ChainInfo = 0x04
|
||||
};
|
||||
|
||||
/// RuntimeFunction - An entry in the table of functions with unwind info.
|
||||
struct RuntimeFunction {
|
||||
uint64_t startAddress;
|
||||
uint64_t endAddress;
|
||||
uint64_t unwindInfoOffset;
|
||||
};
|
||||
|
||||
/// UnwindInfo - An entry in the exception table.
|
||||
struct UnwindInfo {
|
||||
uint8_t version:3,
|
||||
flags:5;
|
||||
uint8_t prologSize;
|
||||
uint8_t numCodes;
|
||||
uint8_t frameRegister:4,
|
||||
frameOffset:4;
|
||||
UnwindCode unwindCodes[1];
|
||||
|
||||
void *getLanguageSpecificData() {
|
||||
return reinterpret_cast<void *>(&unwindCodes[(numCodes+1) & ~1]);
|
||||
}
|
||||
uint64_t getLanguageSpecificHandlerOffset() {
|
||||
return *reinterpret_cast<uint64_t *>(getLanguageSpecificData());
|
||||
}
|
||||
void setLanguageSpecificHandlerOffset(uint64_t offset) {
|
||||
*reinterpret_cast<uint64_t *>(getLanguageSpecificData()) = offset;
|
||||
}
|
||||
RuntimeFunction *getChainedFunctionEntry() {
|
||||
return reinterpret_cast<RuntimeFunction *>(getLanguageSpecificData());
|
||||
}
|
||||
void *getExceptionData() {
|
||||
return reinterpret_cast<void *>(reinterpret_cast<uint64_t *>(
|
||||
getLanguageSpecificData())+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // End of namespace Win64EH
|
||||
} // End of namespace llvm
|
||||
|
||||
#endif
|
@ -128,6 +128,11 @@ class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
|
||||
// dags: (RegClass SubRegIndex, SubRegindex, ...)
|
||||
list<dag> SubRegClasses = [];
|
||||
|
||||
// isAllocatable - Specify that the register class can be used for virtual
|
||||
// registers and register allocation. Some register classes are only used to
|
||||
// model instruction operand constraints, and should have isAllocatable = 0.
|
||||
bit isAllocatable = 1;
|
||||
|
||||
// MethodProtos/MethodBodies - These members can be used to insert arbitrary
|
||||
// code into a generated register class. The normal usage of this is to
|
||||
// overload virtual methods.
|
||||
@ -151,6 +156,14 @@ class DwarfRegNum<list<int> Numbers> {
|
||||
list<int> DwarfNumbers = Numbers;
|
||||
}
|
||||
|
||||
// DwarfRegAlias - This class declares that a given register uses the same dwarf
|
||||
// numbers as another one. This is useful for making it clear that the two
|
||||
// registers do have the same number. It also lets us build a mapping
|
||||
// from dwarf register number to llvm register.
|
||||
class DwarfRegAlias<Register reg> {
|
||||
Register DwarfAlias = reg;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Pull in the common support for scheduling
|
||||
//
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace llvm {
|
||||
class MCSection;
|
||||
class MCContext;
|
||||
class MachineFunction;
|
||||
class TargetMachine;
|
||||
class TargetLoweringObjectFile;
|
||||
|
||||
@ -58,6 +59,18 @@ class TargetAsmInfo {
|
||||
return TLOF->getEHFrameSection();
|
||||
}
|
||||
|
||||
const MCSection *getDwarfFrameSection() const {
|
||||
return TLOF->getDwarfFrameSection();
|
||||
}
|
||||
|
||||
const MCSection *getWin64EHFuncTableSection(StringRef Suffix) const {
|
||||
return TLOF->getWin64EHFuncTableSection(Suffix);
|
||||
}
|
||||
|
||||
const MCSection *getWin64EHTableSection(StringRef Suffix) const {
|
||||
return TLOF->getWin64EHTableSection(Suffix);
|
||||
}
|
||||
|
||||
unsigned getFDEEncoding(bool CFI) const {
|
||||
return TLOF->getFDEEncoding(CFI);
|
||||
}
|
||||
@ -66,6 +79,10 @@ class TargetAsmInfo {
|
||||
return TLOF->isFunctionEHFrameSymbolPrivate();
|
||||
}
|
||||
|
||||
const unsigned *getCalleeSavedRegs(MachineFunction *MF = 0) const {
|
||||
return TRI->getCalleeSavedRegs(MF);
|
||||
}
|
||||
|
||||
unsigned getDwarfRARegNum(bool isEH) const {
|
||||
return TRI->getDwarfRegNum(TRI->getRARegister(), isEH);
|
||||
}
|
||||
@ -77,6 +94,14 @@ class TargetAsmInfo {
|
||||
int getDwarfRegNum(unsigned RegNum, bool isEH) const {
|
||||
return TRI->getDwarfRegNum(RegNum, isEH);
|
||||
}
|
||||
|
||||
int getLLVMRegNum(unsigned DwarfRegNum, bool isEH) const {
|
||||
return TRI->getLLVMRegNum(DwarfRegNum, isEH);
|
||||
}
|
||||
|
||||
int getSEHRegNum(unsigned RegNum) const {
|
||||
return TRI->getSEHRegNum(RegNum);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -122,7 +122,8 @@ class InstrItineraryData {
|
||||
|
||||
InstrItineraryData(const InstrStage *S, const unsigned *OS,
|
||||
const unsigned *F, const InstrItinerary *I)
|
||||
: Stages(S), OperandCycles(OS), Forwardings(F), Itineraries(I) {}
|
||||
: Stages(S), OperandCycles(OS), Forwardings(F), Itineraries(I),
|
||||
IssueWidth(0) {}
|
||||
|
||||
/// isEmpty - Returns true if there are no itineraries.
|
||||
///
|
||||
|
@ -51,6 +51,7 @@ class TargetLibraryInfo : public ImmutablePass {
|
||||
static char ID;
|
||||
TargetLibraryInfo();
|
||||
TargetLibraryInfo(const Triple &T);
|
||||
explicit TargetLibraryInfo(const TargetLibraryInfo &TLI);
|
||||
|
||||
/// has - This function is used by optimizations that want to match on or form
|
||||
/// a given library function.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user