{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/44036","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/44036/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/44036/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/44036/events","html_url":"https://github.com/rust-lang/rust/issues/44036","id":251953129,"number":44036,"title":"Expose target cpu to conditional compilation","user":{"login":"dylanmckay","id":7722159,"avatar_url":"https://avatars0.githubusercontent.com/u/7722159?v=4","gravatar_id":"","url":"https://api.github.com/users/dylanmckay","html_url":"https://github.com/dylanmckay","followers_url":"https://api.github.com/users/dylanmckay/followers","following_url":"https://api.github.com/users/dylanmckay/following{/other_user}","gists_url":"https://api.github.com/users/dylanmckay/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanmckay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanmckay/subscriptions","organizations_url":"https://api.github.com/users/dylanmckay/orgs","repos_url":"https://api.github.com/users/dylanmckay/repos","events_url":"https://api.github.com/users/dylanmckay/events{/privacy}","received_events_url":"https://api.github.com/users/dylanmckay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-08-22T13:15:55Z","updated_at":"2017-08-23T13:27:38Z","closed_at":null,"body":"I've recently created a crate that provides IO/microcontroller specific constants to Rust programs written for the [AVR architecture](https://github.com/avr-rust/rust).\r\n\r\n[avrd on GitHub](https://github.com/avr-rust/avrd)\r\n[avrd on Docs.rs](https://docs.rs/avrd)\r\n\r\nI've made it so that there is always a `current` module in the crate root that reexports all items from a microcontroller-specific crate, depending on what CPU is being targeted.\r\n\r\nIn order to achieve this, I needed to add a `target_cpu` conditional compilation flag to my fork of the Rust compiler\r\n\r\nhttps://github.com/avr-rust/rust/commit/1f5f6bd8f85e905ffb5da6389e879277f7f6b708\r\n\r\nI would like to upstream this (with cleanups like more documentation), as it seems generally useful, but it also would make it easier to merge the fork into mainline if that were to ever happen in the future. On top of this, it would be quite a useful feature to other people who fork Rust for more esoteric architectures.\r\n\r\nThe in-tree targets don't seem to specify CPUs most of the time - looking in the `librustc_back` module, it looks like some targets set CPU to `cortex-a8`, some to a CPU name used by Sparc, but almost everything else is left blank, generic, or \"x86_64\", etc.\r\n\r\nBefore I file a PR, are there any glaring objections to this?"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/324330757","html_url":"https://github.com/rust-lang/rust/issues/44036#issuecomment-324330757","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/44036","id":324330757,"user":{"login":"dylanmckay","id":7722159,"avatar_url":"https://avatars0.githubusercontent.com/u/7722159?v=4","gravatar_id":"","url":"https://api.github.com/users/dylanmckay","html_url":"https://github.com/dylanmckay","followers_url":"https://api.github.com/users/dylanmckay/followers","following_url":"https://api.github.com/users/dylanmckay/following{/other_user}","gists_url":"https://api.github.com/users/dylanmckay/gists{/gist_id}","starred_url":"https://api.github.com/users/dylanmckay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dylanmckay/subscriptions","organizations_url":"https://api.github.com/users/dylanmckay/orgs","repos_url":"https://api.github.com/users/dylanmckay/repos","events_url":"https://api.github.com/users/dylanmckay/events{/privacy}","received_events_url":"https://api.github.com/users/dylanmckay/received_events","type":"User","site_admin":false},"created_at":"2017-08-23T13:27:38Z","updated_at":"2017-08-23T13:27:38Z","body":"> Does each device have a subtly different ISA?\r\n\r\n**tl;dr** Sometimes, yes\r\n\r\nIn general, all devices can be _more or less_ grouped into families.\r\n\r\nFor example, `avr1`, `avr2`, `avr25`, ... `avr5`, `avr51`, are all family names. These families each define an subset of the full AVR ISA.\r\n\r\nYou can find the AVR backend's definition of these families in [AVRDevices.td](https://github.com/llvm-mirror/llvm/blob/master/lib/Target/AVR/AVRDevices.td#L153). You can see that in general, the families build up on top of each other in terms of supported instructions/features.\r\n\r\nThe problem is that not every realised ISA can be cleanly separated into a family.\r\n\r\nFor example, the [ATtiny26](https://github.com/llvm-mirror/llvm/blob/master/lib/Target/AVR/AVRDevices.td#L255) is a part of the `avr2` family, but it also happens to support the \"LPMX\" set of instructions\r\n\r\nAnother example is the [ATMega8515](https://github.com/llvm-mirror/llvm/blob/master/lib/Target/AVR/AVRDevices.td#L315), which _almost_ implements all of `avr4`, but not quite all, and so the linked definition bases the device off `avr2` and adds the extra features explicitly.\r\n\r\n> Does the backend need to know about peripherals?\r\n\r\nNo\r\n\r\n> Or why do you want the LLVM backend to know when it's targeting, for example, \"atmega328\"?\r\n\r\nSolely for deciding what subset of the ISA is supported.All device-specific information required (or used) by the backend can be found inside [AVRDevices.td](https://github.com/llvm-mirror/llvm/blob/master/lib/Target/AVR/AVRDevices.td).\r\n"}}
{"actor":{"display_login":"dylanmckay"}}