Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(first steps of) SR module construction from DR #87

Merged
merged 1 commit into from
Sep 12, 2019

Conversation

kvark
Copy link
Member

@kvark kvark commented Aug 14, 2019

This is based on #86 (which is based on #71 ).


This change is Reviewable

@kvark kvark requested a review from antiagainst August 14, 2019 14:43
@kvark kvark force-pushed the sr-module branch 2 times, most recently from 2137843 to 6e11bff Compare August 15, 2019 14:50
@antiagainst
Copy link
Collaborator

Is this meant to be reviewed? Would be nice to address the conflicts if so. :)

Copy link
Contributor

@Skepfyr Skepfyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo! It looks good, it wil change a bit when rebased but I don't think any major changes are required. The only thing I'm unsure of is whether this is the right place to put it, we could move this into a seperate module as it is essentially a second parser, then again it's all internal so it doesn't matter too much where we put it. (I also go back on my previous statement, I think it's a bad idea to put it in a From impl as they are generally assumed to be reasonably lightweight)
Lastly, it would probably be good to spread about a few more comments as to which bits still need to be implemented just so that nothing gets forgotten.

/// All entry point declarations, using OpEntryPoint.
pub entry_points: Vec<instructions::EntryPoint>,
/// All execution mode declarations, using OpExecutionMode.
pub execution_modes: Vec<instructions::ExecutionMode>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you removed this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's a part of struct EntryPoint

.as_ref()
.ok_or(ConversionError::MissingFunction)?
)?;
let fty = function_type_map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be sensible to add a check that the function type matches the type of the parameters function (or at least a TODO in there)

/// All OpExtension instructions.
pub extensions: Vec<instructions::Extension>,
pub extensions: Vec<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you changed these? I can see pros and cons to both ways round. Also, if this is changed what should happen to the things in instructions atm?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are getting any benefit from using instructions::Extension instead of String, are we? SR module is supposed to be human-friendly, so reducing unnecessary bloat will make it better.

Copy link
Contributor

@Skepfyr Skepfyr Aug 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible, just need to be careful that we keep support of unknown extended instruction sets. (i.e. not GLSL or OpenCL)

@kvark
Copy link
Member Author

kvark commented Sep 3, 2019

@aioob could you remind me where we stand on the standalone types topic?

  1. needed, and Function is standalone
  2. needed, but Function is a variant of Op
  3. not needed

@Skepfyr
Copy link
Contributor

Skepfyr commented Sep 4, 2019

From my point of view, they just aren't needed (although I don't care between 2&3 that much, 3 is preferable as it's less code); they artificially limit what we can represent with no real benefit. However, I haven't looked at the code for a while and would happily accept 1 if anyone can show me a strong benefit it provides.

@kvark
Copy link
Member Author

kvark commented Sep 5, 2019

@antiagainst this is ready to be reviewed now

@kvark
Copy link
Member Author

kvark commented Sep 12, 2019

@aioob @antiagainst anybody?.. review please

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay!

.as_ref()
.ok_or(ConversionError::MissingFunction)?
)?;
/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can we delete commented-out code? They should be added when really supported. Comments are intended for documentation.

}

Ok(module::Module {
header: match module.header {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the DR header is useful to be carried over to SR generally. (Only the version is useful there. We can discard the other fields.) If this is to be handled later, it would be nice to have a TODO here.

sr::constants::Constant,
sr::instructions,
sr::ops::{self, Op},
sr::storage::*,
sr::types::Type,
};
pub use crate::dr::ModuleHeader;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I don't think we should just carray over the module header here. What's the intended usage of it in SR? The version can just be a field on the module.

let module = dr::load_bytes(blob).unwrap();
let _disasm = module.disassemble();
let _assembly = module.assemble();
//TODO: unlock when ready
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this TODO for? The following line is not commented out?

};

use std::path::PathBuf;

fn test_spv(blob: &[u8]) {
let module = dr::load_bytes(blob).unwrap();
let _disasm = module.disassemble();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about the leading _ in names. Is this a Rust convention?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's recognized by the compiler as a sign that a variable is not used.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. Thanks!

}

impl LiftContext {
/// Convert a module from the data representation into structured.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ... structured representation.

Let's be clear (even verbose) on documentation. They are meant to help understanding. :)

.ok_or(ConversionError::MissingLabel)?,
)?;*/
basic_blocks.push(module::BasicBlock {
//label: context.labels.append(label),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use TODOs for unimplemented stuff?

}
}

/// Error that may oocur during the convesion from the data representation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

occur

This PR introduces the conversion routine to the "lift" module as well
as the appropriate error types.
@kvark
Copy link
Member Author

kvark commented Sep 12, 2019

Oh snap, I force-pushed again, sorry!
All the things you mentioned (thank you!) are addressed now.

Copy link
Collaborator

@antiagainst antiagainst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kvark kvark merged commit 9e36643 into gfx-rs:master Sep 12, 2019
@kvark kvark deleted the sr-module branch September 12, 2019 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants