Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Hercules
Commits
a347103d
Commit
a347103d
authored
6 months ago
by
Aaron Councilman
Browse files
Options
Downloads
Patches
Plain Diff
Reimplement create_constant_zero in builder for Juno codegen
parent
52f5d493
No related branches found
Branches containing commit
No related tags found
1 merge request
!32
Reimplement create_constant_zero in builder for Juno codegen
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hercules_ir/src/build.rs
+34
-7
34 additions, 7 deletions
hercules_ir/src/build.rs
with
34 additions
and
7 deletions
hercules_ir/src/build.rs
+
34
−
7
View file @
a347103d
...
...
@@ -354,14 +354,41 @@ impl<'a> Builder<'a> {
pub
fn
create_constant_array
(
&
mut
self
,
elem_ty
:
TypeID
,
extents
:
Box
<
[
u32
]
>
,
)
->
BuilderResult
<
ConstantID
>
{
let
extents
=
extents
.iter
()
.map
(|
extent
|
self
.create_dynamic_constant_constant
(
*
extent
as
usize
))
.collect
();
extents
:
Box
<
[
DynamicConstantID
]
>
,
)
->
ConstantID
{
let
ty
=
self
.create_type_array
(
elem_ty
,
extents
);
Ok
(
self
.intern_constant
(
Constant
::
Array
(
ty
),
ty
))
self
.intern_constant
(
Constant
::
Array
(
ty
),
ty
)
}
pub
fn
create_constant_zero
(
&
mut
self
,
typ
:
TypeID
)
->
ConstantID
{
match
&
self
.module.types
[
typ
.idx
()]
{
Type
::
Control
(
_
)
=>
panic!
(
"Cannot create constant for control types"
),
Type
::
Boolean
=>
self
.create_constant_bool
(
false
),
Type
::
Integer8
=>
self
.create_constant_i8
(
0
),
Type
::
Integer16
=>
self
.create_constant_i16
(
0
),
Type
::
Integer32
=>
self
.create_constant_i32
(
0
),
Type
::
Integer64
=>
self
.create_constant_i64
(
0
),
Type
::
UnsignedInteger8
=>
self
.create_constant_u8
(
0
),
Type
::
UnsignedInteger16
=>
self
.create_constant_u16
(
0
),
Type
::
UnsignedInteger32
=>
self
.create_constant_u32
(
0
),
Type
::
UnsignedInteger64
=>
self
.create_constant_u64
(
0
),
Type
::
Float32
=>
self
.create_constant_f32
(
0.0
),
Type
::
Float64
=>
self
.create_constant_f64
(
0.0
),
Type
::
Product
(
fs
)
=>
{
let
mut
cs
=
vec!
[];
for
t
in
fs
.clone
()
{
cs
.push
(
self
.create_constant_zero
(
t
));
}
self
.create_constant_prod
(
cs
.into
())
},
Type
::
Summation
(
cs
)
=>
{
assert!
(
cs
.len
()
>=
1
,
"Cannot create zero for empty summation"
);
let
c
=
self
.create_constant_zero
(
cs
[
0
]);
self
.create_constant_sum
(
typ
,
0
,
c
)
.expect
(
"Exists and well typed by construction"
)
},
Type
::
Array
(
t
,
dims
)
=>
self
.create_constant_array
(
*
t
,
dims
.clone
()),
}
}
pub
fn
create_dynamic_constant_constant
(
&
mut
self
,
val
:
usize
)
->
DynamicConstantID
{
...
...
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