Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
2f68f2ea
Commit
2f68f2ea
authored
5 years ago
by
Akash Kothari
Browse files
Options
Downloads
Patches
Plain Diff
Update Keywords for LLVM-9 and attributes for HPVM
parent
683cec5d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp
+167
-39
167 additions, 39 deletions
hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp
with
167 additions
and
39 deletions
hpvm/llvm_patches/lib/AsmParser/LLLexer.cpp
+
167
−
39
View file @
2f68f2ea
//===- LLLexer.cpp - Lexer for .ll Files ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
...
...
@@ -157,9 +156,10 @@ static const char *isLabelTail(const char *CurPtr) {
// Lexer definition.
//===----------------------------------------------------------------------===//
LLLexer
::
LLLexer
(
StringRef
StartBuf
,
SourceMgr
&
sm
,
SMDiagnostic
&
Err
,
LLLexer
::
LLLexer
(
StringRef
StartBuf
,
SourceMgr
&
SM
,
SMDiagnostic
&
Err
,
LLVMContext
&
C
)
:
CurBuf
(
StartBuf
),
ErrorInfo
(
Err
),
SM
(
sm
),
Context
(
C
),
APFloatVal
(
0.0
)
{
:
CurBuf
(
StartBuf
),
ErrorInfo
(
Err
),
SM
(
SM
),
Context
(
C
),
APFloatVal
(
0.0
),
IgnoreColonInIdentifiers
(
false
)
{
CurPtr
=
CurBuf
.
begin
();
}
...
...
@@ -219,6 +219,10 @@ lltok::Kind LLLexer::LexToken() {
SkipLineComment
();
continue
;
case
'!'
:
return
LexExclaim
();
case
'^'
:
return
LexCaret
();
case
':'
:
return
lltok
::
colon
;
case
'#'
:
return
LexHash
();
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
...
...
@@ -328,6 +332,22 @@ bool LLLexer::ReadVarName() {
return
false
;
}
// Lex an ID: [0-9]+. On success, the ID is stored in UIntVal and Token is
// returned, otherwise the Error token is returned.
lltok
::
Kind
LLLexer
::
LexUIntID
(
lltok
::
Kind
Token
)
{
if
(
!
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
])))
return
lltok
::
Error
;
for
(
++
CurPtr
;
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
]));
++
CurPtr
)
/*empty*/
;
uint64_t
Val
=
atoull
(
TokStart
+
1
,
CurPtr
);
if
((
unsigned
)
Val
!=
Val
)
Error
(
"invalid value number (too large)!"
);
UIntVal
=
unsigned
(
Val
);
return
Token
;
}
lltok
::
Kind
LLLexer
::
LexVar
(
lltok
::
Kind
Var
,
lltok
::
Kind
VarID
)
{
// Handle StringConstant: \"[^\"]*\"
if
(
CurPtr
[
0
]
==
'"'
)
{
...
...
@@ -357,17 +377,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
return
Var
;
// Handle VarID: [0-9]+
if
(
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
])))
{
for
(
++
CurPtr
;
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
]));
++
CurPtr
)
/*empty*/
;
uint64_t
Val
=
atoull
(
TokStart
+
1
,
CurPtr
);
if
((
unsigned
)
Val
!=
Val
)
Error
(
"invalid value number (too large)!"
);
UIntVal
=
unsigned
(
Val
);
return
VarID
;
}
return
lltok
::
Error
;
return
LexUIntID
(
VarID
);
}
/// Lex all tokens that start with a % character.
...
...
@@ -420,22 +430,18 @@ lltok::Kind LLLexer::LexExclaim() {
return
lltok
::
exclaim
;
}
/// Lex all tokens that start with a ^ character.
/// SummaryID ::= ^[0-9]+
lltok
::
Kind
LLLexer
::
LexCaret
()
{
// Handle SummaryID: ^[0-9]+
return
LexUIntID
(
lltok
::
SummaryID
);
}
/// Lex all tokens that start with a # character.
/// AttrGrpID ::= #[0-9]+
lltok
::
Kind
LLLexer
::
LexHash
()
{
// Handle AttrGrpID: #[0-9]+
if
(
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
])))
{
for
(
++
CurPtr
;
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
]));
++
CurPtr
)
/*empty*/
;
uint64_t
Val
=
atoull
(
TokStart
+
1
,
CurPtr
);
if
((
unsigned
)
Val
!=
Val
)
Error
(
"invalid value number (too large)!"
);
UIntVal
=
unsigned
(
Val
);
return
lltok
::
AttrGrpID
;
}
return
lltok
::
Error
;
return
LexUIntID
(
lltok
::
AttrGrpID
);
}
/// Lex a label, integer type, keyword, or hexadecimal integer constant.
...
...
@@ -457,8 +463,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KeywordEnd
=
CurPtr
;
}
// If we stopped due to a colon, this really is a label.
if
(
*
CurPtr
==
':'
)
{
// If we stopped due to a colon, unless we were directed to ignore it,
// this really is a label.
if
(
!
IgnoreColonInIdentifiers
&&
*
CurPtr
==
':'
)
{
StrVal
.
assign
(
StartChar
-
1
,
CurPtr
++
);
return
lltok
::
LabelStr
;
}
...
...
@@ -494,6 +501,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
declare
);
KEYWORD
(
define
);
KEYWORD
(
global
);
KEYWORD
(
constant
);
KEYWORD
(
dso_local
);
KEYWORD
(
dso_preemptable
);
KEYWORD
(
private
);
KEYWORD
(
internal
);
KEYWORD
(
available_externally
);
...
...
@@ -542,12 +552,15 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
release
);
KEYWORD
(
acq_rel
);
KEYWORD
(
seq_cst
);
KEYWORD
(
s
inglethread
);
KEYWORD
(
s
yncscope
);
KEYWORD
(
nnan
);
KEYWORD
(
ninf
);
KEYWORD
(
nsz
);
KEYWORD
(
arcp
);
KEYWORD
(
contract
);
KEYWORD
(
reassoc
);
KEYWORD
(
afn
);
KEYWORD
(
fast
);
KEYWORD
(
nuw
);
KEYWORD
(
nsw
);
...
...
@@ -557,6 +570,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
align
);
KEYWORD
(
addrspace
);
KEYWORD
(
section
);
KEYWORD
(
partition
);
KEYWORD
(
alias
);
KEYWORD
(
ifunc
);
KEYWORD
(
module
);
...
...
@@ -578,6 +592,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
arm_apcscc
);
KEYWORD
(
arm_aapcscc
);
KEYWORD
(
arm_aapcs_vfpcc
);
KEYWORD
(
aarch64_vector_pcs
);
KEYWORD
(
msp430_intrcc
);
KEYWORD
(
avr_intrcc
);
KEYWORD
(
avr_signalcc
);
...
...
@@ -587,7 +602,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
spir_func
);
KEYWORD
(
intel_ocl_bicc
);
KEYWORD
(
x86_64_sysvcc
);
KEYWORD
(
x86_64_
win64cc
);
KEYWORD
(
win64cc
);
KEYWORD
(
x86_regcallcc
);
KEYWORD
(
webkit_jscc
);
KEYWORD
(
swiftcc
);
...
...
@@ -600,6 +615,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
hhvm_ccc
);
KEYWORD
(
cxx_fast_tlscc
);
KEYWORD
(
amdgpu_vs
);
KEYWORD
(
amdgpu_ls
);
KEYWORD
(
amdgpu_hs
);
KEYWORD
(
amdgpu_es
);
KEYWORD
(
amdgpu_gs
);
KEYWORD
(
amdgpu_ps
);
KEYWORD
(
amdgpu_cs
);
...
...
@@ -632,6 +650,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
nobuiltin
);
KEYWORD
(
nocapture
);
KEYWORD
(
noduplicate
);
KEYWORD
(
nofree
);
KEYWORD
(
noimplicitfloat
);
KEYWORD
(
noinline
);
KEYWORD
(
norecurse
);
...
...
@@ -639,7 +658,10 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
nonnull
);
KEYWORD
(
noredzone
);
KEYWORD
(
noreturn
);
KEYWORD
(
nosync
);
KEYWORD
(
nocf_check
);
KEYWORD
(
nounwind
);
KEYWORD
(
optforfuzzing
);
KEYWORD
(
optnone
);
KEYWORD
(
optsize
);
KEYWORD
(
readnone
);
...
...
@@ -647,23 +669,27 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
returned
);
KEYWORD
(
returns_twice
);
KEYWORD
(
signext
);
KEYWORD
(
speculatable
);
KEYWORD
(
sret
);
KEYWORD
(
ssp
);
KEYWORD
(
sspreq
);
KEYWORD
(
sspstrong
);
KEYWORD
(
strictfp
);
KEYWORD
(
safestack
);
KEYWORD
(
shadowcallstack
);
KEYWORD
(
sanitize_address
);
KEYWORD
(
sanitize_hwaddress
);
KEYWORD
(
sanitize_memtag
);
KEYWORD
(
sanitize_thread
);
KEYWORD
(
sanitize_memory
);
KEYWORD
(
speculative_load_hardening
);
KEYWORD
(
swifterror
);
KEYWORD
(
swiftself
);
KEYWORD
(
uwtable
);
KEYWORD
(
willreturn
);
KEYWORD
(
writeonly
);
KEYWORD
(
zeroext
);
// VISC parameter attributes
KEYWORD
(
in
);
KEYWORD
(
out
);
KEYWORD
(
inout
);
KEYWORD
(
immarg
);
KEYWORD
(
type
);
KEYWORD
(
opaque
);
...
...
@@ -685,6 +711,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
xchg
);
KEYWORD
(
nand
);
KEYWORD
(
max
);
KEYWORD
(
min
);
KEYWORD
(
umax
);
KEYWORD
(
umin
);
KEYWORD
(
vscale
);
KEYWORD
(
x
);
KEYWORD
(
blockaddress
);
...
...
@@ -700,6 +727,84 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD
(
catch
);
KEYWORD
(
filter
);
// Summary index keywords.
KEYWORD
(
path
);
KEYWORD
(
hash
);
KEYWORD
(
gv
);
KEYWORD
(
guid
);
KEYWORD
(
name
);
KEYWORD
(
summaries
);
KEYWORD
(
flags
);
KEYWORD
(
linkage
);
KEYWORD
(
notEligibleToImport
);
KEYWORD
(
live
);
KEYWORD
(
dsoLocal
);
KEYWORD
(
canAutoHide
);
KEYWORD
(
function
);
KEYWORD
(
insts
);
KEYWORD
(
funcFlags
);
KEYWORD
(
readNone
);
KEYWORD
(
readOnly
);
KEYWORD
(
noRecurse
);
KEYWORD
(
returnDoesNotAlias
);
KEYWORD
(
noInline
);
KEYWORD
(
calls
);
KEYWORD
(
callee
);
KEYWORD
(
hotness
);
KEYWORD
(
unknown
);
KEYWORD
(
hot
);
KEYWORD
(
critical
);
KEYWORD
(
relbf
);
KEYWORD
(
variable
);
KEYWORD
(
vTableFuncs
);
KEYWORD
(
virtFunc
);
KEYWORD
(
aliasee
);
KEYWORD
(
refs
);
KEYWORD
(
typeIdInfo
);
KEYWORD
(
typeTests
);
KEYWORD
(
typeTestAssumeVCalls
);
KEYWORD
(
typeCheckedLoadVCalls
);
KEYWORD
(
typeTestAssumeConstVCalls
);
KEYWORD
(
typeCheckedLoadConstVCalls
);
KEYWORD
(
vFuncId
);
KEYWORD
(
offset
);
KEYWORD
(
args
);
KEYWORD
(
typeid
);
KEYWORD
(
typeidCompatibleVTable
);
KEYWORD
(
summary
);
KEYWORD
(
typeTestRes
);
KEYWORD
(
kind
);
KEYWORD
(
unsat
);
KEYWORD
(
byteArray
);
KEYWORD
(
inline
);
KEYWORD
(
single
);
KEYWORD
(
allOnes
);
KEYWORD
(
sizeM1BitWidth
);
KEYWORD
(
alignLog2
);
KEYWORD
(
sizeM1
);
KEYWORD
(
bitMask
);
KEYWORD
(
inlineBits
);
KEYWORD
(
wpdResolutions
);
KEYWORD
(
wpdRes
);
KEYWORD
(
indir
);
KEYWORD
(
singleImpl
);
KEYWORD
(
branchFunnel
);
KEYWORD
(
singleImplName
);
KEYWORD
(
resByArg
);
KEYWORD
(
byArg
);
KEYWORD
(
uniformRetVal
);
KEYWORD
(
uniqueRetVal
);
KEYWORD
(
virtualConstProp
);
KEYWORD
(
info
);
KEYWORD
(
byte
);
KEYWORD
(
bit
);
KEYWORD
(
varFlags
);
// VISC parameter attributes
KEYWORD
(
in
);
KEYWORD
(
out
);
KEYWORD
(
inout
);
#undef KEYWORD
// Keywords for types.
...
...
@@ -734,6 +839,8 @@ lltok::Kind LLLexer::LexIdentifier() {
} \
} while (false)
INSTKEYWORD
(
fneg
,
FNeg
);
INSTKEYWORD
(
add
,
Add
);
INSTKEYWORD
(
fadd
,
FAdd
);
INSTKEYWORD
(
sub
,
Sub
);
INSTKEYWORD
(
fsub
,
FSub
);
INSTKEYWORD
(
mul
,
Mul
);
INSTKEYWORD
(
fmul
,
FMul
);
...
...
@@ -767,6 +874,7 @@ lltok::Kind LLLexer::LexIdentifier() {
INSTKEYWORD
(
invoke
,
Invoke
);
INSTKEYWORD
(
resume
,
Resume
);
INSTKEYWORD
(
unreachable
,
Unreachable
);
INSTKEYWORD
(
callbr
,
CallBr
);
INSTKEYWORD
(
alloca
,
Alloca
);
INSTKEYWORD
(
load
,
Load
);
...
...
@@ -813,17 +921,27 @@ lltok::Kind LLLexer::LexIdentifier() {
return
lltok
::
DIFlag
;
}
if
(
Keyword
.
startswith
(
"DISPFlag"
))
{
StrVal
.
assign
(
Keyword
.
begin
(),
Keyword
.
end
());
return
lltok
::
DISPFlag
;
}
if
(
Keyword
.
startswith
(
"CSK_"
))
{
StrVal
.
assign
(
Keyword
.
begin
(),
Keyword
.
end
());
return
lltok
::
ChecksumKind
;
}
if
(
Keyword
==
"NoDebug"
||
Keyword
==
"FullDebug"
||
Keyword
==
"LineTablesOnly"
)
{
Keyword
==
"LineTablesOnly"
||
Keyword
==
"DebugDirectivesOnly"
)
{
StrVal
.
assign
(
Keyword
.
begin
(),
Keyword
.
end
());
return
lltok
::
EmissionKind
;
}
if
(
Keyword
==
"GNU"
||
Keyword
==
"None"
||
Keyword
==
"Default"
)
{
StrVal
.
assign
(
Keyword
.
begin
(),
Keyword
.
end
());
return
lltok
::
NameTableKind
;
}
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
// the CFE to avoid forcing it to deal with 64-bit numbers.
if
((
TokStart
[
0
]
==
'u'
||
TokStart
[
0
]
==
's'
)
&&
...
...
@@ -945,7 +1063,17 @@ lltok::Kind LLLexer::LexDigitOrNegative() {
for
(;
isdigit
(
static_cast
<
unsigned
char
>
(
CurPtr
[
0
]));
++
CurPtr
)
/*empty*/
;
// Check to see if this really is a label afterall, e.g. "-1:".
// Check if this is a fully-numeric label:
if
(
isdigit
(
TokStart
[
0
])
&&
CurPtr
[
0
]
==
':'
)
{
uint64_t
Val
=
atoull
(
TokStart
,
CurPtr
);
++
CurPtr
;
// Skip the colon.
if
((
unsigned
)
Val
!=
Val
)
Error
(
"invalid value number (too large)!"
);
UIntVal
=
unsigned
(
Val
);
return
lltok
::
LabelID
;
}
// Check to see if this really is a string label, e.g. "-1:".
if
(
isLabelChar
(
CurPtr
[
0
])
||
CurPtr
[
0
]
==
':'
)
{
if
(
const
char
*
End
=
isLabelTail
(
CurPtr
))
{
StrVal
.
assign
(
TokStart
,
End
-
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment