aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/src/ptx.lalrpop
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2021-06-06 17:25:05 +0200
committerAndrzej Janik <[email protected]>2021-06-06 17:25:05 +0200
commite940b9400fe9e67bb9ffdb79ab6d81f31cf88877 (patch)
tree2a18aa5870020ef83dcaae4c2a6d0bf4a62d744f /ptx/src/ptx.lalrpop
parent491e71e346b267dd647e5a17d8fecca2a08e0f53 (diff)
downloadZLUDA-e940b9400fe9e67bb9ffdb79ab6d81f31cf88877.tar.gz
ZLUDA-e940b9400fe9e67bb9ffdb79ab6d81f31cf88877.zip
Bring back support for dynamic shared memory
Diffstat (limited to 'ptx/src/ptx.lalrpop')
-rw-r--r--ptx/src/ptx.lalrpop38
1 files changed, 23 insertions, 15 deletions
diff --git a/ptx/src/ptx.lalrpop b/ptx/src/ptx.lalrpop
index e8370cd..b697317 100644
--- a/ptx/src/ptx.lalrpop
+++ b/ptx/src/ptx.lalrpop
@@ -343,10 +343,16 @@ TargetSpecifier = {
Directive: Option<ast::Directive<'input, ast::ParsedArgParams<'input>>> = {
AddressSize => None,
- <f:Function> => Some(ast::Directive::Method(f)),
+ <f:Function> => {
+ let (linking, func) = f;
+ Some(ast::Directive::Method(linking, func))
+ },
File => None,
Section => None,
- <v:ModuleVariable> ";" => Some(ast::Directive::Variable(v)),
+ <v:ModuleVariable> ";" => {
+ let (linking, var) = v;
+ Some(ast::Directive::Variable(linking, var))
+ },
! => {
let err = <>;
errors.push(err.error);
@@ -358,11 +364,13 @@ AddressSize = {
".address_size" U8Num
};
-Function: ast::Function<'input, &'input str, ast::Statement<ast::ParsedArgParams<'input>>> = {
- LinkingDirectives
+Function: (ast::LinkingDirective, ast::Function<'input, &'input str, ast::Statement<ast::ParsedArgParams<'input>>>) = {
+ <linking:LinkingDirectives>
<func_directive:MethodDeclaration>
<tuning:TuningDirective*>
- <body:FunctionBody> => ast::Function{<>}
+ <body:FunctionBody> => {
+ (linking, ast::Function{func_directive, tuning, body})
+ }
};
LinkingDirective: ast::LinkingDirective = {
@@ -598,18 +606,18 @@ SharedVariable: ast::Variable<&'input str> = {
}
}
-ModuleVariable: ast::Variable<&'input str> = {
- LinkingDirectives ".global" <def:GlobalVariableDefinitionNoArray> => {
+ModuleVariable: (ast::LinkingDirective, ast::Variable<&'input str>) = {
+ <linking:LinkingDirectives> ".global" <def:GlobalVariableDefinitionNoArray> => {
let (align, v_type, name, array_init) = def;
let state_space = ast::StateSpace::Global;
- ast::Variable { align, v_type, state_space, name, array_init }
+ (linking, ast::Variable { align, v_type, state_space, name, array_init })
},
- LinkingDirectives ".shared" <def:GlobalVariableDefinitionNoArray> => {
+ <linking:LinkingDirectives> ".shared" <def:GlobalVariableDefinitionNoArray> => {
let (align, v_type, name, array_init) = def;
let state_space = ast::StateSpace::Shared;
- ast::Variable { align, v_type, state_space, name, array_init: Vec::new() }
+ (linking, ast::Variable { align, v_type, state_space, name, array_init: Vec::new() })
},
- <ldirs:LinkingDirectives> <space:Or<".global", ".shared">> <var:VariableArrayOrPointer<SizedScalarType>> =>? {
+ <linking:LinkingDirectives> <space:Or<".global", ".shared">> <var:VariableArrayOrPointer<SizedScalarType>> =>? {
let (align, t, name, arr_or_ptr) = var;
let (v_type, state_space, array_init) = match arr_or_ptr {
ast::ArrayOrPointer::Array { dimensions, init } => {
@@ -620,17 +628,17 @@ ModuleVariable: ast::Variable<&'input str> = {
}
}
ast::ArrayOrPointer::Pointer => {
- if !ldirs.contains(ast::LinkingDirective::EXTERN) {
+ if !linking.contains(ast::LinkingDirective::EXTERN) {
return Err(ParseError::User { error: ast::PtxError::NonExternPointer });
}
if space == ".global" {
- (ast::Type::Scalar(t), ast::StateSpace::Global, Vec::new())
+ (ast::Type::Array(t, Vec::new()), ast::StateSpace::Global, Vec::new())
} else {
- (ast::Type::Scalar(t), ast::StateSpace::Shared, Vec::new())
+ (ast::Type::Array(t, Vec::new()), ast::StateSpace::Shared, Vec::new())
}
}
};
- Ok(ast::Variable{ align, v_type, state_space, name, array_init })
+ Ok((linking, ast::Variable{ align, v_type, state_space, name, array_init }))
}
}